- 博客(115)
- 收藏
- 关注
原创 Leetcode no. 106
106. Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exi
2016-08-31 21:24:46
388
原创 Leetcode no. 105
105. Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist
2016-08-31 19:54:29
481
原创 Leetcode no. 98
98. Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only no
2016-08-30 21:02:52
399
原创 Leetcode no. 329
329. Longest Increasing Path in a MatrixGiven an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or
2016-08-30 17:28:14
442
原创 Leetcode no. 128
128. Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longes
2016-08-15 12:48:59
423
原创 Leetcode no. 14
14. Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.public class Solution { public String longestCommonPrefix(String[] st
2016-08-15 11:09:01
389
原创 Leetcode no. 45
45. Jump Game IIGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at tha
2016-08-14 17:24:33
300
原创 leetcode no. 55
55. Jump GameGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that p
2016-08-14 14:35:43
384
原创 Leetcode no. 96
96. Unique Binary Search TreesGiven n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's.
2016-08-11 23:58:43
406
原创 Leetcode no. 94
94. Binary Tree Inorder TraversalGiven a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3
2016-08-11 22:00:22
398
原创 Leetcode no. 67
67. Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".public class Solution { public String addBinary(Stri
2016-08-11 21:17:26
337
原创 Leetcode no. 145
145. Binary Tree Postorder TraversalGiven a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3
2016-08-11 20:56:17
292
原创 Leetcode no. 144
144. Binary Tree Preorder TraversalGiven a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3
2016-08-11 19:42:36
304
原创 Leetcode no. 221
221. Maximal SquareGiven a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.For example, given the following matrix:1 0 1 0 01
2016-07-30 16:29:50
439
原创 Leetcode no. 194
194. Transpose FileGiven a text file file.txt, transpose its content.You may assume that each row has the same number of columns and each field is separated by the ' ' character.Fo
2016-07-29 16:54:10
341
原创 Leetcode no. 193
193. Valid Phone NumbersGiven a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers.You may assume tha
2016-07-29 16:13:11
601
原创 Leetcode no. 192
192. Word FrequencyWrite a bash script to calculate the frequency of each word in a text file words.txt.For simplicity sake, you may assume:words.txt contains only lowercase characte
2016-07-29 13:16:15
359
原创 Leetcode no. 149
149. Max Points on a LineGiven n points on a 2D plane, find the maximum number of points that lie on the same straight line./** * Definition for a point. * class Point { *
2016-07-26 20:59:19
470
原创 Leetcode no. 179
179. Largest NumberGiven a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.
2016-07-17 12:28:49
321
原创 Leetcode no. 134
134. Gas StationThere are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to t
2016-07-17 11:48:23
303
原创 Leetcode no. 41
41. First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm shoul
2016-07-09 23:40:01
261
原创 Leetcode no. 8
8. String to Integer (atoi)Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yo
2016-06-26 00:12:29
288
原创 Leetcode no. 162
162. Find Peak ElementA peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array
2016-06-25 22:51:35
339
原创 Leetcode no. 168
168. Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 ->
2016-06-24 15:26:16
406
原创 Leetcode no. 171
171. Excel Sheet Column NumberRelated to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A
2016-06-24 15:10:14
281
原创 Leetcode no. 172
172. Factorial Trailing ZeroesGiven an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.public class Solution {
2016-06-24 14:51:19
334
原创 Leetcode no. 338
338. Counting BitsGiven a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an arr
2016-06-24 14:14:13
325
原创 Leetcode no. 347
347. Top K Frequent ElementsGiven 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 ass
2016-06-24 13:50:27
474
1
原创 Leetcode no. 72
72. Edit DistanceGiven two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 oper
2016-06-23 11:18:46
305
原创 Leetcode no. 91
91. Decode WaysA message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits,
2016-06-22 11:17:53
316
原创 Leetcode no. 38
38. Count and SayThe 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 as "two 1s"
2016-06-22 00:44:29
242
原创 Leetcode no. 237
237. Delete Node in a Linked ListWrite 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
2016-06-21 21:55:12
263
原创 Leetcode no. 236
236. Lowest Common Ancestor of a Binary TreeGiven a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “Th
2016-06-20 23:35:04
555
原创 Leetcode no. 111
111. Minimum Depth of Binary TreeGiven 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 leaf
2016-06-18 21:18:50
315
原创 Leetcode no. 107
107. Binary Tree Level Order Traversal IIGiven 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).
2016-06-18 20:32:42
389
原创 Leetcode no. 102
102. Binary Tree Level Order TraversalGiven 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
2016-06-18 00:55:31
287
原创 Leetcode no. 124
124. Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tr
2016-06-18 00:37:32
336
原创 Leetcode no. 136
136. Single NumberGiven an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you im
2016-06-06 11:45:00
264
原创 Leetcode no. 306
306. Additive NumberAdditive number is a string whose digits can form additive sequence.A valid additive sequence should contain at least three numbers. Except for the first two numbers,
2016-06-01 17:15:52
391
原创 Leetcode no. 258
258. Add DigitsGiven 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: 3 + 8 = 11, 1
2016-06-01 00:51:54
284
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人