随笔分类 -  LeetCode 题目

238. Product of Array Except Self
摘要:Given an array ofnintegers wheren> 1,nums, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Solv... 阅读全文

posted @ 2015-07-31 07:14 shini 阅读(119) 评论(0) 推荐(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 thedefinition of LCA on Wikipedia: ... 阅读全文

posted @ 2015-07-31 04:58 shini 阅读(126) 评论(0) 推荐(0)

234. Palindrome Linked List
摘要:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?先找到链表中点,将第二部分反转,然后比较两部分链表的值。/** * De... 阅读全文

posted @ 2015-07-31 00:56 shini 阅读(168) 评论(0) 推荐(0)

232. Implement Queue using Stacks
摘要:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front o... 阅读全文

posted @ 2015-07-11 06:43 shini 阅读(106) 评论(0) 推荐(0)

231. Power of Two
摘要:Given an integer, write a function to determine if it is a power of two.Credits:Special thanks to@jianchao.li.fighterfor adding this problem and creat... 阅读全文

posted @ 2015-07-11 06:35 shini 阅读(214) 评论(0) 推荐(0)

58. Length of Last Word
摘要:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe... 阅读全文

posted @ 2015-07-01 11:00 shini 阅读(173) 评论(0) 推荐(0)

228. Summary Ranges
摘要:Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"].Credits:S... 阅读全文

posted @ 2015-06-27 08:53 shini 阅读(128) 评论(0) 推荐(0)

55. Jump Game && 45. Jump Game II
摘要: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 yo... 阅读全文

posted @ 2015-06-25 09:26 shini 阅读(105) 评论(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,−1,2,1,... 阅读全文

posted @ 2015-06-25 09:08 shini 阅读(89) 评论(0) 推荐(0)

Permutations
摘要:Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,... 阅读全文

posted @ 2015-06-18 07:54 shini 阅读(127) 评论(0) 推荐(0)

221. Maximal Square
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matr... 阅读全文

posted @ 2015-06-17 07:40 shini 阅读(106) 评论(0) 推荐(0)

226. Invert Binary Tree
摘要:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired bythis... 阅读全文

posted @ 2015-06-17 07:23 shini 阅读(89) 评论(0) 推荐(0)

225. Implement Stack using Queues
摘要:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()... 阅读全文

posted @ 2015-06-12 08:23 shini 阅读(115) 评论(0) 推荐(0)

222. Count Complete Tree Nodes
摘要:Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, except... 阅读全文

posted @ 2015-06-09 09:13 shini 阅读(145) 评论(0) 推荐(0)

223. Rectangle Area
摘要:Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ... 阅读全文

posted @ 2015-06-09 08:45 shini 阅读(81) 评论(0) 推荐(0)

40. Combination Sum II
摘要:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Each number ... 阅读全文

posted @ 2015-06-05 07:34 shini 阅读(110) 评论(0) 推荐(0)

39. Combination Sum
摘要:Given a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thesamerepeated num... 阅读全文

posted @ 2015-06-05 07:27 shini 阅读(157) 评论(0) 推荐(0)

38. Count and Say
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw... 阅读全文

posted @ 2015-06-05 07:10 shini 阅读(154) 评论(0) 推荐(0)

38. Valid Sudoku
摘要:Determine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with ... 阅读全文

posted @ 2015-06-04 09:08 shini 阅读(140) 评论(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 @ 2015-06-04 08:30 shini 阅读(154) 评论(0) 推荐(0)

导航