03 2017 档案
141. Linked List Cycle
摘要:Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 阅读全文
posted @ 2017-03-20 19:44 Ci_pea 阅读(104) 评论(0) 推荐(0)
136. Single Number
摘要:Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime complex 阅读全文
posted @ 2017-03-20 19:38 Ci_pea 阅读(158) 评论(0) 推荐(0)
125. Valid Palindrome
摘要:Given a string, determine if it is a palindrome(回文), considering only alphanumeric(字母数字的) characters and ignoring cases. For example,"A man, a plan, a 阅读全文
posted @ 2017-03-20 19:00 Ci_pea 阅读(162) 评论(0) 推荐(0)
122. Best Time to Buy and Sell Stock II
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2017-03-18 20:02 Ci_pea 阅读(162) 评论(0) 推荐(0)
121. Best Time to Buy and Sell Stock
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2017-03-18 19:43 Ci_pea 阅读(130) 评论(0) 推荐(0)
119. Pascal's Triangle II
摘要:Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. 自己写的~~ for i in range(1,2): i 只能取到1 阅读全文
posted @ 2017-03-18 19:05 Ci_pea 阅读(203) 评论(0) 推荐(0)
118. Pascal's Triangle
摘要:Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return explanation: Any row can be constructed using th 阅读全文
posted @ 2017-03-18 17:09 Ci_pea 阅读(184) 评论(0) 推荐(0)
112. Path Sum
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. F 阅读全文
posted @ 2017-03-18 16:59 Ci_pea 阅读(122) 评论(0) 推荐(0)
110. Balanced Binary Tree
摘要:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the dept 阅读全文
posted @ 2017-03-16 17:25 Ci_pea 阅读(167) 评论(0) 推荐(0)
108. Convert Sorted Array to Binary Search Tree
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. mid = (len(nums)-1) // 2 也是正确的 阅读全文
posted @ 2017-03-15 19:03 Ci_pea 阅读(107) 评论(0) 推荐(0)
107. Binary Tree Level Order Traversal II
摘要:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For 阅读全文
posted @ 2017-03-15 18:57 Ci_pea 阅读(124) 评论(0) 推荐(0)
111. Minimum Depth of Binary Tree
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文
posted @ 2017-03-15 18:08 Ci_pea 阅读(95) 评论(0) 推荐(0)
104. Maximum Depth of Binary Tree
摘要:Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文
posted @ 2017-03-15 16:58 Ci_pea 阅读(112) 评论(0) 推荐(0)
101. Symmetric Tree
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2017-03-15 16:37 Ci_pea 阅读(122) 评论(0) 推荐(0)
100. Same Tree
摘要:Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical a 阅读全文
posted @ 2017-03-15 15:42 Ci_pea 阅读(96) 评论(0) 推荐(0)
88. Merge Sorted Array
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size tha 阅读全文
posted @ 2017-03-15 15:22 Ci_pea 阅读(106) 评论(0) 推荐(0)
83. Remove Duplicates from Sorted List
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, 阅读全文
posted @ 2017-03-15 14:52 Ci_pea 阅读(111) 评论(0) 推荐(0)
70. Climbing Stairs
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2017-03-14 19:49 Ci_pea 阅读(102) 评论(0) 推荐(0)
69. Sqrt(x)
摘要:Implement int sqrt(int x). Compute and return the square root of x. 牛顿法 二分法 阅读全文
posted @ 2017-03-14 19:22 Ci_pea 阅读(108) 评论(0) 推荐(0)
67. Add Binary
摘要:Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". bin():将整数x转换为二进制字符串,前面会带'0b'; int(a,2),a是二 阅读全文
posted @ 2017-03-14 18:55 Ci_pea 阅读(124) 评论(0) 推荐(0)
66. Plus One
摘要:Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any leadin 阅读全文
posted @ 2017-03-14 15:48 Ci_pea 阅读(158) 评论(0) 推荐(0)
58. Length of Last Word
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word 阅读全文
posted @ 2017-03-14 15:16 Ci_pea 阅读(134) 评论(0) 推荐(0)
53. Maximum Subarray
摘要:Find the contiguous(连续的) subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4, 阅读全文
posted @ 2017-03-14 14:52 Ci_pea 阅读(127) 评论(0) 推荐(0)
38. Count and Say
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11.11 is read off 阅读全文
posted @ 2017-03-14 10:57 Ci_pea 阅读(132) 评论(0) 推荐(0)
35. Search Insert Position
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2017-03-13 10:55 Ci_pea 阅读(128) 评论(0) 推荐(0)
28. Implement strStr()
摘要:Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 阅读全文
posted @ 2017-03-13 10:26 Ci_pea 阅读(165) 评论(0) 推荐(0)
27. Remove Element
摘要:Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you 阅读全文
posted @ 2017-03-13 09:49 Ci_pea 阅读(115) 评论(0) 推荐(0)
26. Remove Duplicates from Sorted Array
摘要:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space fo 阅读全文
posted @ 2017-03-10 10:56 Ci_pea 阅读(96) 评论(0) 推荐(0)
21. Merge Two Sorted Lists
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 上面程序Fail 阅读全文
posted @ 2017-03-10 10:33 Ci_pea 阅读(115) 评论(0) 推荐(0)
20. Valid Parentheses
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文
posted @ 2017-03-06 13:58 Ci_pea 阅读(100) 评论(0) 推荐(0)
14. Longest Common Prefix
摘要:Write a function to find the longest common prefix(前缀) string amongst an array of strings. 注意strs[i][j]不要超出范围 阅读全文
posted @ 2017-03-02 10:02 Ci_pea 阅读(109) 评论(0) 推荐(0)