- 博客(307)
- 资源 (3)
- 收藏
- 关注
原创 The Power of Two Random Choices - Summary
Algorithm Introduction: IntroductionPaper: The Power of Two Random Choices
2017-02-16 13:53:01
1106
原创 [LeetCode 267] Palindrome Permutation II
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form.For example:Given s = "aabb", return ["
2016-04-04 08:10:43
3287
原创 [Leetcode 266] Palindrome Permutation
Given a string, determine if a permutation of the string could form a palindrome.For example,"code" -> False, "aab" -> True, "carerac" -> True.Solution1 - Hashtable, store number of each c
2016-04-04 06:57:58
1307
原创 [LeetCode 330] Patching array
Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the array. Re
2016-03-20 09:36:44
1412
原创 [LeetCode 332] Reconstruct Itinerary
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus
2016-03-20 09:25:38
2787
原创 [LeetCode 335] Self Crossing
You are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west, x[2] metres to the south, x[3]metres to the east and so
2016-03-20 09:22:14
1397
原创 [LeetCode 329] Longest Increasing Path in a Matrix
Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside
2016-02-21 08:49:34
2152
原创 [LeetCode328] Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in
2016-02-21 03:27:21
729
原创 [LeetCode 324] Wiggle Sort II
Given an unsorted array nums, reorder it such that nums[0] nums[2] .Example:(1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5, 1, 6]. (2) Given nums = [1, 3, 2, 2, 3
2016-01-13 17:18:23
2948
原创 [LeetCode 326] Power of Three
Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?Solution:3^x=nlog(3^x) = log(n)x log(3) = log(n)
2016-01-13 17:11:38
4439
原创 [LeetCode 318] Maximum Product of Word Lengths
Given 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 lett
2016-01-12 16:25:17
4113
原创 [LeetCode 322] Coin Change
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of mone
2016-01-12 16:22:11
3447
原创 [LeetCode 316] Remove Duplicate Letters
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order a
2015-12-28 16:57:02
5123
原创 [LeetCode 313] Super Ugly Number
Write a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4, 7, 8, 13,
2015-12-28 11:18:08
2595
原创 [LeetCode 310] Minimum Height Trees
For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called mini
2015-12-28 06:26:31
4455
原创 [LeetCode 319] Bulb switch
There 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 off
2015-12-28 03:34:09
1555
原创 [LeetCode306] Additive Number
Additive number is a string whose digits can form additive sequence.A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the
2015-12-06 03:56:30
3230
原创 [LeetCode 307] Range Sum Query - Mutable
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by updating the element at index i to val.Examp
2015-12-04 14:57:13
3184
原创 [LeetCode303] Range Sum Query - Immutable
Given 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]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRan
2015-12-02 16:27:26
919
原创 [LeetCode 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 makes a guess, you provide a hint t
2015-11-19 16:19:07
1389
原创 [LeetCode 297] Serialize and Deserialize Binary Tree
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be
2015-11-18 16:28:34
1741
原创 [LeetCode 295] Find Median from Data Stream
Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4] , the median
2015-10-25 05:17:18
2683
原创 [LeetCode294] Flip Game II
Flip Game II -- LeetCode 294You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip twoconsecutive "++" into "--". The g
2015-10-18 08:08:17
5111
原创 [LeetCode 293] Flip Game
You are playing the following Flip Game with your friend: Given a string that contains only these two characters:+ and-, you and your friend take turns to flip two consecutive"++" into "--". The g
2015-10-18 07:41:45
4599
原创 [LeetCode 292] Nim Game
You 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 to 3 stones. The one who removes the last stone will be the
2015-10-13 13:16:54
3584
原创 [LeetCode 253] Meeting Rooms II
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si For example,Given [[0, 30],[5, 10],[15, 20]],return 2.solution:put start and nega
2015-10-13 12:41:13
4802
原创 [LeetCode 252] Meeting Rooms
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si , determine if a person could attend all meetings.For example,Given [[0, 30],[5, 10],[15, 2
2015-10-12 07:24:33
1833
原创 [LeetCode 289] Game of Life
According to the Wikipedia's article: "The Game of Life, also known simply asLife, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given a board with m b
2015-10-12 07:07:53
1890
原创 [LeetCode 282] Expression Add Operator
Given a string that contains only digits 0-9 and a target value, return all possibilities to addbinary operators (not unary) +, -, or * between the digits so they evaluate to the target value.Ex
2015-10-09 13:31:54
2527
原创 [LeetCode 290] Word Pattern
Given a pattern and a string str, find if str follows the same pattern.Examples:pattern = "abba", str = "dog cat cat dog" should return true.pattern = "abba", str = "dog cat cat fish" should r
2015-10-09 11:44:41
4074
原创 [LeetCode 218] The Skyline Problem
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you aregiven the locations and height of all the buildings a
2015-10-08 14:51:40
1642
原创 System Design 之 Tiny Uri
http://www.zhihu.com/question/29270034?sort=createdRequirement1. Generate short url, from long to short url2. Recover long url, from short to long url. 3. is there lifetime of tiny url?Cou
2015-10-05 14:44:41
1007
原创 [LeetCode 214] Shortest Palindrome
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.For exampl
2015-10-05 13:40:45
1650
原创 [LeetCode 174] Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially pos
2015-09-30 13:59:17
719
原创 [LeetCode 188] Best Time to Buy and Sell Stock IV
Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may not
2015-09-29 13:14:02
968
原创 [LeetCode 287] Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 andn (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, f
2015-09-29 11:51:19
2778
翻译 kafka in a nutshell -- kafka 简介
Kafka is a messaging system. That’s it. So why all the hype? In realitymessaging is a hugely important piece of infrastructure for moving data betweensystems. To see why, let’s look at a data pipeline
2015-09-26 08:14:00
1212
原创 [LeetCode 156] Binary Tree Upside Down
Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it upside down and turn it into a tree where the origin
2015-09-25 14:59:31
718
原创 [LeetCode 283] Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your fu
2015-09-24 07:19:32
3578
原创 [LeetCode 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:Special thanks to @jianchao.li.fighter fo
2015-09-24 04:07:18
482
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人