- 博客(9)
- 资源 (5)
- 收藏
- 关注
原创 LeetCode 240: Search a 2D Matrix II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in
2015-07-30 19:07:55 1716
原创 LeetCode 14: Longest Common Prefix
Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.求最长公共前缀。代码如下:class Solution {public: string longestCommonPrefix(vect
2015-07-30 19:04:07 1810
原创 LeetCode 238: Product of Array Except Self
Given an array of n integers where n > 1, nums, return an arrayoutput such that output[i] is equal to the product of all the elements ofnums except nums[i].Solve it without division and in O(n).
2015-07-27 18:51:41 4103 3
原创 LeetCode 235: Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betwee
2015-07-27 18:41:00 2674
原创 LeetCode 237 : Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value
2015-07-27 13:54:09 6830 2
原创 LeetCode 234: Palindrome Linked List (回文链表)
Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?判断一个单向链表是否是回文链表,要求O(n)的时间复杂度和O(1)的空间复杂度。算法有以下几种:1、遍历整个链表,将链表每个节点的值记录在数组中,再判断数组是不是一个回文数
2015-07-16 22:48:30 15943 3
原创 LeetCode 232: Implement Queue using Stacks
Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty(
2015-07-07 19:35:06 5165
原创 LeetCode 231: Power of Two
Given an integer, write a function to determine if it is a power of two.判断一个数是否是2的幂,判断方法主要依据2的N次幂的特点:仅有首位为1,其余各位都为0.方法1: n & n-1 == 0class Solution {public: bool isPowerOfTwo(int n) {
2015-07-06 18:34:20 4388 2
原创 LeetCode 230: Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find thekth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.Follow up:What if the BST
2015-07-02 14:27:17 6865 3
效能桌面便签V1.66
2010-10-18
FsCapture 6.7 for Windows
2010-10-18
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人