09 2015 档案

[LeetCode] Find the Duplicate Number
摘要:Find the Duplicate NumberGiven an arraynumscontainingn+ 1 integers where each integer is between 1 andn(inclusive), prove that at least one duplicate ... 阅读全文

posted @ 2015-09-28 13:41 Eason Liu 阅读(446) 评论(0) 推荐(0)

[LeetCode] Walls and Gates
摘要:Walls and GatesYou are given am x n2D grid initialized with these three possible values.-1- A wall or an obstacle.0- A gate.INF- Infinity means an emp... 阅读全文

posted @ 2015-09-25 13:02 Eason Liu 阅读(666) 评论(0) 推荐(0)

[LeetCode] Expression Add Operators
摘要:Expression Add OperatorsGiven a string that contains only digits0-9and a target value, return all possibilities to addbinaryoperators (not unary)+,-, ... 阅读全文

posted @ 2015-09-22 16:43 Eason Liu 阅读(435) 评论(0) 推荐(0)

[LeetCode] Inorder Successor in BST
摘要:Inorder Successor in BSTGiven a binary search tree and a node in it, find the in-order successor of that node in the BST.Note: If the given node has n... 阅读全文

posted @ 2015-09-22 14:47 Eason Liu 阅读(697) 评论(0) 推荐(0)

[LeetCode] Peeking Iterator
摘要:Peeking IteratorGiven an Iterator class interface with methods:next()andhasNext(), design and implement a PeekingIterator that support thepeek()operat... 阅读全文

posted @ 2015-09-21 18:40 Eason Liu 阅读(373) 评论(0) 推荐(0)

[CTCI] 最小调整有序
摘要:最小调整有序题目描述有一个整数数组,请编写一个函数,找出索引m和n,只要将m和n之间的元素排好序,整个数组就是有序的。注意:n-m应该越小越好,也就是说,找出符合条件的最短序列。给定一个int数组A和数组的大小n,请返回一个二元组,代表所求序列的起点和终点。(原序列位置从0开始标号,若原序列有序,返... 阅读全文

posted @ 2015-09-20 22:41 Eason Liu 阅读(477) 评论(0) 推荐(0)

[LeetCode] Single Number III
摘要:Single Number IIIGiven an array of numbersnums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find t... 阅读全文

posted @ 2015-09-16 00:11 Eason Liu 阅读(219) 评论(0) 推荐(0)

[LeetCode] Zigzag Iterator
摘要:Zigzag IteratorGiven two 1d vectors, implement an iterator to return their elements alternately.For example, given two 1d vectors:v1 = [1, 2]v2 = [3, ... 阅读全文

posted @ 2015-09-14 13:02 Eason Liu 阅读(650) 评论(0) 推荐(0)

[LeetCode] Wiggle Sort
摘要:Wiggle SortGiven an unsorted arraynums, reorder itin-placesuch thatnums[0] = nums[2] & nums) { 4 int flag = 1; 5 for (int i = 1; i < n... 阅读全文

posted @ 2015-09-10 18:37 Eason Liu 阅读(1382) 评论(0) 推荐(0)

[LeetCode] First Bad Version
摘要:First Bad VersionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fa... 阅读全文

posted @ 2015-09-07 21:11 Eason Liu 阅读(282) 评论(0) 推荐(1)

[LeetCode] Missing Ranges
摘要:Missing RangesGiven a sorted integer array where the range of elements are [lower,upper] inclusive, return its missing ranges.For example, given[0, 1,... 阅读全文

posted @ 2015-09-07 13:07 Eason Liu 阅读(212) 评论(0) 推荐(0)

[LeetCode] Find the Celebrity
摘要:Find the CelebritySuppose you are at a party withnpeople (labeled from0ton - 1) and among them, there may exist one celebrity. The definition of a cel... 阅读全文

posted @ 2015-09-06 13:11 Eason Liu 阅读(7177) 评论(0) 推荐(0)

[LeetCode] Longest Substring with At Most Two Distinct Characters
摘要:Longest Substring with At Most Two Distinct CharactersGiven a string, find the length of the longest substring T that contains at most 2 distinct char... 阅读全文

posted @ 2015-09-06 11:37 Eason Liu 阅读(201) 评论(0) 推荐(0)

[LeetCode] Read N Characters Given Read4 I & II
摘要:Read N Characters Given Read4The API:int read4(char *buf)reads 4 characters at a time from a file.The return value is the actual number of characters ... 阅读全文

posted @ 2015-09-06 11:33 Eason Liu 阅读(617) 评论(0) 推荐(0)

[LeetCode] Meeting Rooms I & II
摘要:Meeting RoomsGiven an array of meeting time intervals consisting of start and end times[[s1,e1],[s2,e2],...](si& intervals) {13 sort(intervals... 阅读全文

posted @ 2015-09-06 11:29 Eason Liu 阅读(375) 评论(0) 推荐(0)

[LeetCode] Graph Valid Tree
摘要:Graph Valid TreeGivennnodes labeled from0ton - 1and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these... 阅读全文

posted @ 2015-09-06 11:17 Eason Liu 阅读(542) 评论(0) 推荐(0)

[LeetCode] Palindrome Permutation I & II
摘要:Palindrome PermutationGiven a string, determine if a permutation of the string could form a palindrome.For example,"code"-> False,"aab"-> True,"carera... 阅读全文

posted @ 2015-09-06 11:12 Eason Liu 阅读(930) 评论(0) 推荐(0)

[LeetCode] Encode and Decode Strings
摘要:Encode and Decode StringsDesign an algorithm to encodea list of stringstoa string. The encoded string is then sent over the network and is decoded bac... 阅读全文

posted @ 2015-09-06 11:08 Eason Liu 阅读(1456) 评论(0) 推荐(0)

[LeetCode] Paint Fence
摘要:Paint FenceThere 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... 阅读全文

posted @ 2015-09-06 11:01 Eason Liu 阅读(1207) 评论(0) 推荐(0)

[LeetCode] Paint House I & II
摘要:Paint HouseThere are a row ofnhouses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with... 阅读全文

posted @ 2015-09-06 10:56 Eason Liu 阅读(2212) 评论(0) 推荐(0)

[LeetCode] Shortest Word Distance I & II & III
摘要:Shortest Word DistanceGiven a list of words and two wordsword1andword2, return the shortest distance between these two words in the list.For example,A... 阅读全文

posted @ 2015-09-06 10:51 Eason Liu 阅读(2139) 评论(0) 推荐(0)