随笔分类 -  Algorithm

1 2 3 4 5 ··· 14 下一页

[LeetCode] Reconstruct Original Digits from English
摘要:Reconstruct Original Digits from English Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits i 阅读全文

posted @ 2017-04-10 16:28 Eason Liu 阅读(385) 评论(0) 推荐(0)

[LeetCode] Coin Change
摘要:Coin ChangeYou are given coins of different denominations and a total amount of moneyamount. Write a function to compute the fewest number of coins th... 阅读全文

posted @ 2015-12-28 13:39 Eason Liu 阅读(2029) 评论(0) 推荐(0)

[LeetCode] Range Sum Query - Immutable & Range Sum Query 2D - Immutable
摘要:Range Sum Query - ImmutableGiven an integer arraynums, find the sum of the elements between indicesiandj(i≤j), inclusive.Example:Given nums = [-2, 0, ... 阅读全文

posted @ 2015-11-16 18:59 Eason Liu 阅读(2291) 评论(0) 推荐(0)

[LeetCode] Longest Increasing Subsequence
摘要:Longest Increasing SubsequenceGiven an unsorted array of integers, find the length of longest increasing subsequence.For example,Given[10, 9, 2, 5, 3,... 阅读全文

posted @ 2015-11-04 13:30 Eason Liu 阅读(362) 评论(0) 推荐(0)

[LeetCode] Bulls and Cows
摘要:Bulls and CowsYou are playing the followingBulls and Cowsgame with your friend: You write a 4-digit secret number and ask your friend to guess it, eac... 阅读全文

posted @ 2015-10-31 21:55 Eason Liu 阅读(2017) 评论(0) 推荐(0)

[LeetCode] Serialize and Deserialize Binary Tree
摘要:Serialize and Deserialize Binary TreeSerialization is the process of converting a data structure or object into a sequence of bits so that it can be s... 阅读全文

posted @ 2015-10-29 17:54 Eason Liu 阅读(565) 评论(0) 推荐(0)

[LeetCode] Find Median from Data Stream
摘要:Find Median from Data StreamMedian is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the m... 阅读全文

posted @ 2015-10-20 22:23 Eason Liu 阅读(632) 评论(0) 推荐(0)

[LeetCode] Convert Sorted List to Binary Search Tree
摘要:Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.... 阅读全文

posted @ 2015-10-19 19:49 Eason Liu 阅读(296) 评论(0) 推荐(0)

[LeetCode] Nim Game
摘要:Nim GameYou are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 t... 阅读全文

posted @ 2015-10-13 14:28 Eason Liu 阅读(456) 评论(0) 推荐(0)

[LeetCode] Word Pattern
摘要:Word PatternGiven apatternand a stringstr, find ifstrfollows the same pattern.Examples:pattern ="abba", str ="dog cat cat dog"should return true.patte... 阅读全文

posted @ 2015-10-06 10:54 Eason Liu 阅读(1672) 评论(0) 推荐(0)

[LeetCode] Unique Word Abbreviation
摘要:Unique Word AbbreviationAn abbreviation of a word follows the form . Below are some examples of word abbreviations:a) it --> it ... 阅读全文

posted @ 2015-10-02 12:52 Eason Liu 阅读(1351) 评论(1) 推荐(0)

[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 阅读(445) 评论(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)

1 2 3 4 5 ··· 14 下一页