随笔分类 -  [LeetCode]

1 2 3 4 5 ··· 8 下一页
摘要:int curInc;HashMap incMap;Stack stack;public SuperStack() { this.curInc = 0; this.incMap = new HashMap(); this.stack = new Stack();} p... 阅读全文
posted @ 2015-10-25 02:23 airforce 阅读(356) 评论(0) 推荐(0)
摘要:Problem:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all... 阅读全文
posted @ 2015-10-02 04:42 airforce 阅读(191) 评论(0) 推荐(0)
摘要:Problem:Find thekth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Fo... 阅读全文
posted @ 2015-10-01 08:23 airforce 阅读(211) 评论(0) 推荐(0)
摘要:Problem:Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You ... 阅读全文
posted @ 2015-09-26 10:32 airforce 阅读(276) 评论(0) 推荐(0)
摘要:Problem:Implement a basic calculator to evaluate a simple expression string.The expression string contains onlynon-negativeintegers,+,-,*,/operators a... 阅读全文
posted @ 2015-09-20 23:18 airforce 阅读(463) 评论(0) 推荐(0)
摘要:Problem:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible repres... 阅读全文
posted @ 2015-09-20 22:16 airforce 阅读(297) 评论(0) 推荐(0)
摘要:Problem:Given an unsorted arraynums, reorder itin-placesuch thatnums[0] = nums[2] = nums[2] = nums[i+1]Note: i is an odd number. Solution 1:public cla... 阅读全文
posted @ 2015-09-20 12:01 airforce 阅读(504) 评论(0) 推荐(0)
摘要:Problem:Given a non-empty binary search tree and a target value, findkvalues in the BST that are closest to the target.Note:Given target value is a fl... 阅读全文
posted @ 2015-09-20 10:58 airforce 阅读(412) 评论(0) 推荐(0)
摘要:Problem:Numbers can be regarded as product of its factors. For example,8 = 2 x 2 x 2; = 2 x 4.Write a function that takes an integernand return all p... 阅读全文
posted @ 2015-09-19 23:29 airforce 阅读(3287) 评论(0) 推荐(0)
摘要:Problem: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 ... 阅读全文
posted @ 2015-09-19 09:28 airforce 阅读(288) 评论(0) 推荐(0)
摘要:Problem:Given two strings S and T, determine if they are both one edit distance apart.General Analysis:This problem is not hard. However, to write out... 阅读全文
posted @ 2015-09-17 08:58 airforce 阅读(191) 评论(0) 推荐(0)
摘要:Problem: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 y... 阅读全文
posted @ 2015-09-17 01:27 airforce 阅读(362) 评论(0) 推荐(0)
摘要:Problem:Suppose you are at a party withnpeople (labeled from0ton - 1) and among them, there may exist one celebrity. The definition of a celebrity is ... 阅读全文
posted @ 2015-09-16 03:32 airforce 阅读(813) 评论(0) 推荐(0)
摘要:Problem:The API:int read4(char *buf)reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it... 阅读全文
posted @ 2015-09-15 23:54 airforce 阅读(606) 评论(0) 推荐(0)
摘要:Problem: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, fl... 阅读全文
posted @ 2015-09-15 04:08 airforce 阅读(1171) 评论(0) 推荐(0)
摘要: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 ... 阅读全文
posted @ 2015-09-15 00:28 airforce 阅读(593) 评论(0) 推荐(0)
摘要:Problem:Given a string, we can "shift" each of its letter to its successive letter, for example:"abc" -> "bcd". We can keep "shifting" which forms the... 阅读全文
posted @ 2015-09-14 08:13 airforce 阅读(993) 评论(0) 推荐(0)
摘要:Problem:Given a binary tree, count the number of uni-value subtrees.A Uni-value subtree means all nodes of the subtree have the same value.For example... 阅读全文
posted @ 2015-09-14 04:37 airforce 阅读(512) 评论(0) 推荐(0)
摘要:Problem:Given a strings, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could ... 阅读全文
posted @ 2015-09-14 02:06 airforce 阅读(713) 评论(0) 推荐(0)
摘要:Problem:Given two 1d vectors, implement an iterator to return their elements alternately.For example, given two 1d vectors:v1 = [1, 2]v2 = [3, 4, 5, 6... 阅读全文
posted @ 2015-09-14 01:18 airforce 阅读(392) 评论(0) 推荐(0)

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