随笔分类 -  leetcode刷题总结

https://oj.leetcode.com/
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana... 阅读全文
posted @ 2014-07-19 13:49 SunshineAtNoon 阅读(170) 评论(0) 推荐(0) 编辑
摘要:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, giv... 阅读全文
posted @ 2014-07-19 11:33 SunshineAtNoon 阅读(174) 评论(0) 推荐(0) 编辑
摘要:Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniq... 阅读全文
posted @ 2014-07-19 11:07 SunshineAtNoon 阅读(193) 评论(0) 推荐(0) 编辑
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文
posted @ 2014-07-19 10:34 SunshineAtNoon 阅读(402) 评论(0) 推荐(0) 编辑
摘要:Implementint sqrt(int x).Compute and return the square root ofx.题解:二分的方法,从0,1,2.....x搜索sqrt(x)的值。代码如下: 1 public class Solution { 2 public int sqrt... 阅读全文
posted @ 2014-07-18 16:02 SunshineAtNoon 阅读(214) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le... 阅读全文
posted @ 2014-07-18 15:29 SunshineAtNoon 阅读(138) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t... 阅读全文
posted @ 2014-07-18 15:18 SunshineAtNoon 阅读(264) 评论(0) 推荐(0) 编辑
摘要:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(... 阅读全文
posted @ 2014-07-18 15:00 SunshineAtNoon 阅读(179) 评论(0) 推荐(0) 编辑
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文
posted @ 2014-07-18 14:40 SunshineAtNoon 阅读(231) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo... 阅读全文
posted @ 2014-07-18 14:11 SunshineAtNoon 阅读(181) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep... 阅读全文
posted @ 2014-07-18 14:00 SunshineAtNoon 阅读(224) 评论(0) 推荐(0) 编辑
摘要:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.题解:参见http://www.cnblogs.com... 阅读全文
posted @ 2014-07-18 11:51 SunshineAtNoon 阅读(154) 评论(0) 推荐(0) 编辑
摘要:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc... 阅读全文
posted @ 2014-07-18 11:41 SunshineAtNoon 阅读(240) 评论(0) 推荐(0) 编辑
摘要:Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Fo... 阅读全文
posted @ 2014-07-18 10:53 SunshineAtNoon 阅读(253) 评论(0) 推荐(0) 编辑
摘要:Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],... 阅读全文
posted @ 2014-07-17 20:19 SunshineAtNoon 阅读(214) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文
posted @ 2014-07-17 19:26 SunshineAtNoon 阅读(164) 评论(0) 推荐(0) 编辑
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret... 阅读全文
posted @ 2014-07-17 17:57 SunshineAtNoon 阅读(232) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文
posted @ 2014-07-17 16:57 SunshineAtNoon 阅读(108) 评论(0) 推荐(0) 编辑
摘要:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No... 阅读全文
posted @ 2014-07-17 16:49 SunshineAtNoon 阅读(850) 评论(1) 推荐(0) 编辑
摘要:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... 阅读全文
posted @ 2014-07-17 15:24 SunshineAtNoon 阅读(228) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示