- 博客(68)
- 收藏
- 关注
转载 [LeetCode]53. Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanat...
2018-09-12 23:08:24
225
转载 [Leetcode]160.Intersection of Two Linked Lists
160 Intersection of Two Linked Lists EasyWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 ...
2018-07-02 21:09:54
246
转载 [LeetCode]2. Add Two Numbers&67. Add Binary
2. Add Two Numbers67. Add Binary
2016-10-16 13:48:32
488
转载 [LeetCode]409. Longest Palindrome
EasyGiven a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example “Aa” is not cons
2016-10-07 00:25:07
395
转载 [LeetCode]39.Combination Sum&40.Combination Sum II&216.Combination Sum III&377.Combination Sum IV
39.Combination Sum40.Combination Sum II216.Combination Sum III377.Combination Sum IV
2016-10-06 23:44:30
477
转载 [LeetCode]223. Rectangle Area
Easy Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Rectangle Area Assume that
2016-10-05 23:53:38
273
转载 [LeetCode]400. Nth Digit
EasyFind the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …Note: n is positive and will fit within the range of a 32-bit signed integer (n < 231).Example 1:Input: 3Ou
2016-10-05 21:26:59
275
转载 [LeetCode]38. Count and Say
EasyThe 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” or 21. 21 is read off as “one 2,
2016-10-05 20:23:41
236
转载 [LeetCode]7. Reverse Integer&190. Reverse Bits
7. Reverse Integer190. Reverse Bits
2016-10-05 17:04:24
259
转载 [LeetCode]189. Rotate Array
EasyRotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note: Try to come up as many solutions as you can,
2016-10-05 15:55:24
255
转载 [LeetCode]343. Integer Break
MediumGiven a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, re
2016-10-05 10:11:07
241
转载 [LeetCode]144. Binary Tree Preorder Traversal&94. Binary Tree Inorder Traversal
144. Binary Tree Preorder Traversal94. Binary Tree Inorder Traversal
2016-10-04 23:27:44
257
转载 [LeetCode]318. Maximum Product of Word Lengths
MediumGiven a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case
2016-10-04 16:58:01
309
转载 [LeetCode]238. Product of Array Except Self
MediumGiven 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 nums[i].Solve it without division and in O(n)
2016-10-04 16:27:34
219
转载 [LeetCode]204. Count Primes
EasyDescription:Count the number of prime numbers less than a non-negative number, n.超时: public int countPrimes(int n) { int[] primes = new int[n/2+1]; int p = 0; int i = 2;
2016-10-04 10:06:19
279
转载 [LeetCode]58. Length of Last Word
EasyGiven 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 does not exist, return 0.Note: A word is define
2016-10-03 17:34:10
239
转载 [LeetCode]257. Binary Tree Paths
EasyGiven a binary tree, return all root-to-leaf paths.For example, given the following binary tree:1 / \ 2 3 \ 5 All root-to-leaf paths are:[“1->2->5”, “1->3”]5ms:public List<String> bi
2016-10-01 16:24:53
266
转载 [LeetCode]118. Pascal's Triangle&119. Pascal's Triangle II
118. Pascal's Triangle119. Pascal's Triangle II
2016-10-01 15:53:39
264
转载 [LeetCode]112. Path Sum&113. Path Sum II
112 . Path Sum EasyGiven 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 below bin
2016-10-01 12:16:35
309
转载 [LeetCode]70. Climbing Stairs
EasyYou 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 climb to the top?0ms:public int climbStairs(int n)
2016-09-29 17:28:49
212
转载 [LeetCode]206. Reverse Linked List&92. Reverse Linked List II
206. Reverse Linked List92. Reverse Linked List II
2016-09-29 17:08:54
262
转载 [LeetCode]235. Lowest Common Ancestor of a Binary Search Tree&236. Lowest Common Ancestor of a Binar
235. Lowest Common Ancestor of a Binary Search Tree236. Lowest Common Ancestor of a Binar
2016-09-29 15:07:31
267
转载 [LeetCode]217. Contains Duplicate&219. Contains Duplicate II&220. Contains Duplicate III
217. Contains Duplicate219. Contains Duplicate II220. Contains Duplicate III
2016-09-28 23:30:19
312
转载 [LeetCode]83. Remove Duplicates from Sorted List
EasyGiven 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, return 1->2->3.2ms: public ListNode deleteD
2016-09-28 22:41:39
210
转载 [LeetCode]401. Binary Watch
EasyA binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with the least significant bit on
2016-09-28 21:58:36
256
转载 [LeetCode]169. Majority Element&229. Majority Element II
169. Majority Element229. Majority Element II
2016-09-28 19:57:21
239
转载 [LeetCode]387. First Unique Character in a String
EasyGiven 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.s = “loveleetcode”, return 2. Note: You may as
2016-09-28 16:40:30
221
转载 [LeetCode]404. Sum of Left Leaves
EasyFind the sum of all left leaves in a given binary tree.Example:3/ \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.9ms: pub
2016-09-28 15:21:25
245
转载 [LeetCode]101. Symmetric Tree
EasyGiven 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 symmetric:1/ \ 2 2 / \ / \ 3 4 4 3 But the
2016-09-17 10:51:37
291
转载 [LeetCode]66. Plus One
EasyGiven 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 at the head of the list.1ms:public int[] plusOne(
2016-09-17 10:50:32
207
转载 [LeetCode]319. Bulb Switcher
MediumThere are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turning
2016-09-17 10:48:31
367
转载 [LeetCode]268. Missing Number
MediumGiven an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] return 2.Note: Your algorithm should run i
2016-09-17 10:46:23
259
转载 [LeetCode]155. Min Stack
EasyDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get
2016-09-17 10:40:47
180
转载 [LeetCode]278. First Bad Version
EasyYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on
2016-09-17 10:38:29
243
转载 [LeetCode]27. Remove Element【&26. Remove Duplicates from Sorted Array】
27. Remove Element26. Remove Duplicates from Sorted Array
2016-09-17 10:34:34
213
转载 [LeetCode]141. Linked List Cycle【&142. Linked List Cycle II】
141. Linked List Cycle142. Linked List Cycle II
2016-09-17 10:27:50
206
转载 [LeetCode]168. Excel Sheet Column Title&171. Excel Sheet Column Number
168. Excel Sheet Column Title171. Excel Sheet Column Number
2016-09-17 10:24:01
216
转载 [LeetCode]104. MaximumDepthOfBinaryTree&110. BalancedBinaryTree&111. MinimumDepthOfBinaryTree
104. Maximum Depth of Binary Tree110. Balanced Binary Tree
2016-09-17 10:19:37
232
转载 [LeetCode]226. Invert Binary Tree
EasyInvert a binary tree. 4/ \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 10ms: public TreeNode invertTree(TreeNode root) { if(root==null)
2016-09-17 10:15:51
178
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人