- 博客(34)
- 收藏
- 关注
原创 Leetcode no. 350
350. Intersection of Two Arrays IIGiven two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Ea
2016-05-31 17:50:37 256
原创 Leetcode no. 349
349. Intersection of Two ArraysGiven two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each ele
2016-05-31 17:30:58 268
原创 Leetcode no. 131
131. Palindrome PartitioningGiven a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, giv
2016-05-30 00:47:48 324
原创 Leetcode no. 152
152. Maximum Product SubarrayFind 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],the con
2016-05-29 19:09:41 295
原创 Leetcode no. 32
32. Longest Valid ParenthesesGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest
2016-05-29 16:46:03 401
原创 Leetcode no. 1
1. Two SumGiven 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 exactly one solution.Exam
2016-05-28 23:05:43 244
原创 Leetcode no. 231
231. Power of TwoGiven an integer, write a function to determine if it is a power of two.public class Solution { public boolean isPowerOfTwo(int n) { return n>0 && (n & (n-
2016-05-28 22:55:17 239
原创 Leetcode no. 112
112. Path SumGiven 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.For example:Given the bel
2016-05-28 22:45:12 246
原创 Leetcode no. 43
43. Multiply StringsGiven two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Conver
2016-05-28 22:26:37 286
原创 Leetcode no. 153
153. Find Minimum in Rotated Sorted ArraySuppose 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
2016-05-28 16:42:12 546
原创 Leetcode no. 212
212. Word Search IIGiven a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjacent cell, where "
2016-05-27 17:48:31 349
原创 Leetcode no. 208
208. Implement Trie (Prefix Tree)Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.class TrieN
2016-05-27 16:48:05 247
原创 Leetcode no. 129
129. Sum Root to Leaf NumbersGiven a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which repr
2016-05-27 12:42:58 356
原创 Leetcode no. 200
200. Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizont
2016-05-27 01:37:56 297
原创 Leetcode no. 110
110. Balanced Binary TreeGiven 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 depth of the two
2016-05-26 21:11:38 401
原创 Leetcode no. 257
257. Binary Tree PathsGiven a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:
2016-05-26 01:15:03 287
原创 Leetcode no. 53
53. Maximum SubarrayFind 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,1,−5,4],the con
2016-05-26 00:14:19 231
原创 Leetcode no. 303
303. Range Sum Query - ImmutableGiven an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRa
2016-05-25 20:50:11 263
原创 Leetcode no. 345
345. Reverse Vowels of a StringWrite a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s
2016-05-25 20:07:08 301
原创 Leetcode no. 344
344. Reverse StringWrite a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".public class Solution { public String
2016-05-25 17:11:16 225
原创 Leetcode no. 220
220. Contains Duplicate IIIGiven an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most
2016-05-25 16:39:24 725
原创 Leetcode no. 219
219. Contains Duplicate IIGiven 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 difference
2016-05-24 23:49:37 271
原创 Leetcode no. 217
217. Contains DuplicateGiven 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 array, and it should r
2016-05-24 23:29:30 207
原创 Leetcode no. 79
79. Word SearchGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those h
2016-05-24 23:06:03 236
原创 Leetcode no. 215
215. Kth Largest Element in an ArrayFind 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 examp
2016-05-21 00:52:13 244
原创 Leetcode no. 165
165. Compare Version NumbersCompare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that th
2016-05-20 14:02:56 316
原创 Leetcode no. 173
173. Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next s
2016-05-19 00:33:32 268
原创 Leetcode no. 142
142. Linked List Cycle IIGiven a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up:Can you solve
2016-05-19 00:16:00 250
原创 Leetcode no. 100
100. Same TreeGiven 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 and the nodes have the s
2016-05-18 23:41:28 252
原创 Leetcode no. 304
304. Range Sum Query 2D - ImmutableGiven a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col
2016-05-17 20:26:31 240
原创 Leetcode no. 75
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, white and blue.Her
2016-05-06 10:32:56 310
原创 Leetcode no. 34
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 order of O(log
2016-05-06 10:28:03 283
原创 Leetcode no. 299
299. Bulls and Cows You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend mak
2016-05-04 10:44:25 356
原创 Leetcode no. 90
90. Subsets II Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solut
2016-05-04 10:39:01 299
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人