387. First Unique Character in a String
摘要:Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0.
阅读全文
posted @
2016-09-28 15:25
Machelsky
阅读(122)
推荐(0)
252. Meeting Rooms
摘要:Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all mee
阅读全文
posted @
2016-09-28 14:59
Machelsky
阅读(163)
推荐(0)
重做169. Majority Element
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the
阅读全文
posted @
2016-09-28 03:44
Machelsky
阅读(85)
推荐(0)
229. Majority Element II
摘要:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. 思路
阅读全文
posted @
2016-09-28 03:41
Machelsky
阅读(116)
推荐(0)
404. Sum of Left Leaves
摘要:Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 1
阅读全文
posted @
2016-09-28 02:02
Machelsky
阅读(210)
推荐(0)
389. Find the Difference
摘要:Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at
阅读全文
posted @
2016-09-28 01:45
Machelsky
阅读(126)
推荐(0)
293. Flip Game
摘要:You are playing the following Flip Game with your friend: Given a string that contains only these two characters: +and -, you and your friend take tur
阅读全文
posted @
2016-09-27 16:23
Machelsky
阅读(109)
推荐(0)
266. Palindrome Permutation
摘要:Given a string, determine if a permutation of the string could form a palindrome. For example,"code" -> False, "aab" -> True, "carerac" -> True. 思路:ha
阅读全文
posted @
2016-09-27 15:22
Machelsky
阅读(175)
推荐(0)
325. Maximum Size Subarray Sum Equals k
摘要:Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead. Example 1: Given
阅读全文
posted @
2016-09-27 14:51
Machelsky
阅读(151)
推荐(0)
209. Minimum Size Subarray Sum
摘要:Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return
阅读全文
posted @
2016-09-27 14:10
Machelsky
阅读(131)
推荐(0)
295. Find Median from Data Stream
摘要:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two
阅读全文
posted @
2016-09-27 11:41
Machelsky
阅读(165)
推荐(0)
74. Search a 2D Matrix
摘要: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 f
阅读全文
posted @
2016-09-25 08:43
Machelsky
阅读(108)
推荐(0)
215. Kth Largest Element in an Array
摘要:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam
阅读全文
posted @
2016-09-25 06:47
Machelsky
阅读(117)
推荐(0)
347. Top K Frequent Elements
摘要:Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assum
阅读全文
posted @
2016-09-25 06:23
Machelsky
阅读(263)
推荐(0)
280. Wiggle Sort
摘要:Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... For example, given nums = [3, 5, 2, 1, 6, 4],
阅读全文
posted @
2016-09-24 17:42
Machelsky
阅读(132)
推荐(0)
75. Sort Colors
摘要:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red,
阅读全文
posted @
2016-09-24 11:14
Machelsky
阅读(143)
推荐(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. 思
阅读全文
posted @
2016-09-24 10:26
Machelsky
阅读(109)
推荐(0)
113. Path Sum II
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and sum
阅读全文
posted @
2016-09-24 06:17
Machelsky
阅读(202)
推荐(0)
重做257. Binary Tree Paths
摘要:Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: Solution1: 用string是最方便的。
阅读全文
posted @
2016-09-24 04:49
Machelsky
阅读(122)
推荐(0)
301. Remove Invalid Parentheses
摘要:Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may cont
阅读全文
posted @
2016-09-24 03:15
Machelsky
阅读(304)
推荐(0)
32. Longest Valid Parentheses
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the lo
阅读全文
posted @
2016-09-24 02:20
Machelsky
阅读(138)
推荐(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 @
2016-09-24 01:45
Machelsky
阅读(123)
推荐(0)
236. Lowest Common Ancestor of a Binary Tree
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes
阅读全文
posted @
2016-09-23 13:50
Machelsky
阅读(106)
推荐(0)
59. Spiral Matrix II
摘要:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example,Given n = 3, You should return the followi
阅读全文
posted @
2016-09-23 08:50
Machelsky
阅读(125)
推荐(0)
54. Spiral Matrix
摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example,Given the following matrix: You s
阅读全文
posted @
2016-09-23 08:26
Machelsky
阅读(114)
推荐(0)
155. Min Stack
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov
阅读全文
posted @
2016-09-23 06:39
Machelsky
阅读(105)
推荐(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 @
2016-09-23 06:04
Machelsky
阅读(109)
推荐(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 @
2016-09-23 05:52
Machelsky
阅读(115)
推荐(0)
103. Binary Tree Zigzag Level Order Traversal
摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and
阅读全文
posted @
2016-09-23 05:19
Machelsky
阅读(169)
推荐(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 @
2016-09-23 05:04
Machelsky
阅读(111)
推荐(0)
102. Binary Tree Level Order Traversal
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3
阅读全文
posted @
2016-09-22 09:18
Machelsky
阅读(143)
推荐(0)
256. Paint House
摘要:There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certai
阅读全文
posted @
2016-09-22 08:40
Machelsky
阅读(540)
推荐(0)
276. Paint Fence
摘要:There is a fence with n posts, each post can be painted with one of the k colors. You have to paint all the posts such that no more than two adjacent
阅读全文
posted @
2016-09-22 08:14
Machelsky
阅读(141)
推荐(0)
364. Nested List Weight Sum II
摘要:Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- w
阅读全文
posted @
2016-09-22 06:54
Machelsky
阅读(191)
推荐(0)
339. Nested List Weight Sum
摘要:Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- w
阅读全文
posted @
2016-09-22 06:20
Machelsky
阅读(174)
推荐(0)
156. Binary Tree Upside Down
摘要:Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it up
阅读全文
posted @
2016-09-22 05:34
Machelsky
阅读(123)
推荐(0)
238. Product of Array Except Self
摘要:Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except
阅读全文
posted @
2016-09-22 05:10
Machelsky
阅读(111)
推荐(0)
152. Maximum Product Subarray
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4],t
阅读全文
posted @
2016-09-22 04:47
Machelsky
阅读(137)
推荐(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,-1,2,
阅读全文
posted @
2016-09-22 04:34
Machelsky
阅读(119)
推荐(0)
205. Isomorphic Strings
摘要:Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrenc
阅读全文
posted @
2016-09-22 04:15
Machelsky
阅读(124)
推荐(0)
34. Search for a Range
摘要:Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the or
阅读全文
posted @
2016-09-22 03:55
Machelsky
阅读(135)
推荐(0)
Bit Manipulation
摘要:非常好的总结 REF:https://discuss.leetcode.com/topic/50315/a-summary-how-to-use-bit-manipulation-to-solve-problems-easily-and-efficiently
阅读全文
posted @
2016-09-22 03:04
Machelsky
阅读(98)
推荐(0)
2. Add Two Numbers
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single
阅读全文
posted @
2016-09-22 02:56
Machelsky
阅读(129)
推荐(0)
167. Two Sum II - Input array is sorted
摘要:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function
阅读全文
posted @
2016-09-21 13:41
Machelsky
阅读(120)
推荐(0)
170. Two Sum III - Data structure design
摘要:Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure.find
阅读全文
posted @
2016-09-21 13:13
Machelsky
阅读(150)
推荐(0)
245. Shortest Word Distance III
摘要:This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same as word2. Given a list of words and two words word1
阅读全文
posted @
2016-09-21 12:37
Machelsky
阅读(157)
推荐(0)
244. Shortest Word Distance II
摘要:This is a follow up of Shortest Word Distance. The only difference is now you are given the list of words and your method will be called repeatedly ma
阅读全文
posted @
2016-09-21 12:07
Machelsky
阅读(142)
推荐(0)
243. Shortest Word Distance
摘要:Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. For example, Assume that words
阅读全文
posted @
2016-09-21 11:40
Machelsky
阅读(124)
推荐(0)
50. Pow(x,n)
摘要:Implement pow(x, n). 看不动书了,简直已经读不进去!!还剩dp和部分hashtable median没看,有兴致再看吧。马丹书上都没有binomial heap为毛老师会讲这种很难实现的数据结构!! Solution1: 思路:递归。要注意把一半的pow存在一个变量再输出,不然复
阅读全文
posted @
2016-09-21 11:17
Machelsky
阅读(132)
推荐(0)
啃书的第四天
摘要:好难啃,大篇幅的证明和theorem醉醉的。CH1,2,3,4,5,6,7,10,16,22,23,24。希望明后天能啃完数据结构和动态规划。。。
阅读全文
posted @
2016-09-20 11:50
Machelsky
阅读(142)
推荐(0)
啃书中
摘要:记啃clrs的第三天。此书自带催眠功能。 Recursion is a "Programming Paradigm" which is generally used to implement the "Algorithmic Paradigm" Divide and Conquer . Ref:ht
阅读全文
posted @
2016-09-19 12:15
Machelsky
阅读(147)
推荐(0)
139. Word Break
摘要:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For
阅读全文
posted @
2016-09-17 11:26
Machelsky
阅读(283)
推荐(0)
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
阅读全文
posted @
2016-09-17 10:47
Machelsky
阅读(167)
推荐(0)
257. Binary Tree Paths
摘要:Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are:
阅读全文
posted @
2016-09-17 09:27
Machelsky
阅读(138)
推荐(0)
49. Group Anagrams
摘要:Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:
阅读全文
posted @
2016-09-17 08:27
Machelsky
阅读(186)
推荐(0)
171. Excel Sheet Column Number
摘要:Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: So
阅读全文
posted @
2016-09-17 07:27
Machelsky
阅读(215)
推荐(0)
78.Subsets
摘要:Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example,If nums =
阅读全文
posted @
2016-09-17 07:03
Machelsky
阅读(135)
推荐(0)
278. First Bad Version
摘要:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c
阅读全文
posted @
2016-09-15 15:19
Machelsky
阅读(146)
推荐(0)
231. Power of Two
摘要:Given an integer, write a function to determine if it is a power of two. Solution1: 检查1的个数,略麻烦。 Solution2: 清零法,跟之前有一道题目很像
阅读全文
posted @
2016-09-15 14:58
Machelsky
阅读(130)
推荐(0)
198. House Robber
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo
阅读全文
posted @
2016-09-15 12:38
Machelsky
阅读(105)
推荐(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 @
2016-09-15 12:25
Machelsky
阅读(103)
推荐(0)
219.Contains Duplicate II
摘要:Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the
阅读全文
posted @
2016-09-15 11:39
Machelsky
阅读(138)
推荐(0)
46. Permutations
摘要:Given a collection of distinct numbers, return all possible permutations. For example,[1,2,3] have the following permutations: Backtracking is a more
阅读全文
posted @
2016-09-14 16:39
Machelsky
阅读(131)
推荐(0)
290. Word Pattern
摘要:Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a lette
阅读全文
posted @
2016-09-14 12:27
Machelsky
阅读(404)
推荐(0)
190. Reverse Bits
摘要:Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), retur
阅读全文
posted @
2016-09-14 11:45
Machelsky
阅读(143)
推荐(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 @
2016-09-14 11:23
Machelsky
阅读(129)
推荐(0)
217. Contains Duplicate
摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr
阅读全文
posted @
2016-09-14 08:51
Machelsky
阅读(161)
推荐(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,-1,2,
阅读全文
posted @
2016-09-13 15:16
Machelsky
阅读(105)
推荐(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 @
2016-09-13 13:41
Machelsky
阅读(126)
推荐(0)
91. Decode Ways
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, determine t
阅读全文
posted @
2016-09-13 13:06
Machelsky
阅读(158)
推荐(0)
371. Sum of Two Integers
摘要:Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example:Given a = 1 and b = 2, return 3. 思路:xor相加存无car
阅读全文
posted @
2016-09-13 11:24
Machelsky
阅读(106)
推荐(0)
242. Valid Anagram
摘要:Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t =
阅读全文
posted @
2016-09-13 10:43
Machelsky
阅读(125)
推荐(0)
234. Palindrome Linked List
摘要:Given a singly linked list, determine if it is a palindrome. 思路:stack存数,然后从头比较。 Solution2: Follow up: O(n) in time, O(1) in space. 思路:用reverse linkedl
阅读全文
posted @
2016-09-13 08:54
Machelsky
阅读(113)
推荐(0)
168. Excel Sheet Column Title
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: Solution2: 把数字减一再运算就不用考虑其他问题了。参考了discussion
阅读全文
posted @
2016-09-13 07:08
Machelsky
阅读(159)
推荐(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 @
2016-09-12 06:41
Machelsky
阅读(126)
推荐(0)
14. Longest Common Prefix
摘要:Write a function to find the longest common prefix string amongst an array of strings. Solution1: 思路:没有想到什么巧妙方法。就用recursion暴力硬做。发现只要想法对,recursion怎么做都能
阅读全文
posted @
2016-09-12 06:31
Machelsky
阅读(166)
推荐(0)
160. Intersection of Two Linked Lists
摘要:Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to in
阅读全文
posted @
2016-09-12 05:20
Machelsky
阅读(134)
推荐(0)
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? Solution1: 思路:有cycle:1.循环退不出来2.有个节点被指两次。
阅读全文
posted @
2016-09-12 04:35
Machelsky
阅读(114)
推荐(0)
9. Palindrome Number
摘要:Determine whether an integer is a palindrome. Do this without extra space. Solution1: 思路:按题目的意思就是负数不能是palindrome。用reverse integer函数判断即可。
阅读全文
posted @
2016-09-12 03:44
Machelsky
阅读(111)
推荐(0)
153. Find Minimum in Rotated Sorted Array
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element.
阅读全文
posted @
2016-09-11 15:18
Machelsky
阅读(132)
推荐(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 @
2016-09-11 14:25
Machelsky
阅读(107)
推荐(0)
148. Sort List
摘要:Sort a linked list in O(n log n) time using constant space complexity. 虽然知道要用mergesort,也懂mergesort,但没有自己实现过。真正上手的时候就不回=。=。参考了discussion的思路。 思路:找到linke
阅读全文
posted @
2016-09-11 07:55
Machelsky
阅读(144)
推荐(0)
121. Best Time to Buy and Sell Stock
摘要:121. Best Time to Buy and Sell Stock 121. Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stoc
阅读全文
posted @
2016-09-11 06:45
Machelsky
阅读(130)
推荐(0)
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 -
阅读全文
posted @
2016-09-11 05:51
Machelsky
阅读(104)
推荐(0)
258. Add Digits
摘要:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like:
阅读全文
posted @
2016-09-11 05:34
Machelsky
阅读(151)
推荐(0)
226. Invert Binary Tree
摘要:Invert a binary tree. to
阅读全文
posted @
2016-09-11 05:14
Machelsky
阅读(125)
推荐(0)
89. 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 @
2016-09-11 04:02
Machelsky
阅读(166)
推荐(0)
283. Move Zeroes
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, giv
阅读全文
posted @
2016-09-11 03:18
Machelsky
阅读(162)
推荐(0)
7. Reverse Integer
摘要:Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Solution1: 这道题做的太麻烦了,corner case很多,碰到负数不知道怎么给reverse。强行转成st
阅读全文
posted @
2016-09-11 03:00
Machelsky
阅读(155)
推荐(0)
151. Reverse Words in a String
摘要:Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Solution1: 不使用任何functiion 昨天
阅读全文
posted @
2016-09-10 12:06
Machelsky
阅读(155)
推荐(0)
13. Roman to Integer
摘要:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 思路:之前一直觉得罗马数字好麻烦,一刷的时候看到就头疼不想做。看了看wiki之后感觉
阅读全文
posted @
2016-09-10 10:49
Machelsky
阅读(524)
推荐(0)
169. Majority Element
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the
阅读全文
posted @
2016-09-10 09:27
Machelsky
阅读(118)
推荐(0)
206. Reverse Linked List
摘要:Reverse a singly linked list. Solution 1: 思路:null的使用。用一个null node来承接,一个一个接上去即可。一刷的时候还觉得这node转化好麻烦好神奇,熟悉之后其实做起来很快。 Solution 2: follow up : Use Recursio
阅读全文
posted @
2016-09-10 08:32
Machelsky
阅读(103)
推荐(0)
66. Plus One
摘要:Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is a
阅读全文
posted @
2016-09-10 08:03
Machelsky
阅读(159)
推荐(0)
15. 3Sum
摘要:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of
阅读全文
posted @
2016-09-10 07:37
Machelsky
阅读(128)
推荐(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 @
2016-09-10 06:24
Machelsky
阅读(136)
推荐(0)
100. Same Tree
摘要:思路:递归。 null也是tree。 null tree (definition) Definition: (1) A tree which is empty. (2) A tree whose leaf nodes all have a null value. https://xlinux.nis
阅读全文
posted @
2016-09-10 05:09
Machelsky
阅读(130)
推荐(0)
191. Number of 1 Bits
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight). For example, the 32-bit i
阅读全文
posted @
2016-09-10 03:42
Machelsky
阅读(194)
推荐(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 comple
阅读全文
posted @
2016-09-09 13:31
Machelsky
阅读(179)
推荐(0)
1. Two Sum
摘要:Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex
阅读全文
posted @
2016-09-09 13:17
Machelsky
阅读(123)
推荐(0)
二刷
摘要:脆跪了expedia。作为转专业的学生,自己还是有点冒进了。基础不扎实,题目不熟练就上去当炮灰。十月之前好好修炼吧,一刷205道,硬着头皮啃下来的骨头确实不好吃。二刷开始~
阅读全文
posted @
2016-09-09 13:05
Machelsky
阅读(151)
推荐(0)