菱纱梦

导航

随笔分类 -  LeetCode

1 2 3 下一页

Patching Array
摘要:引用原文:http://blog.csdn.net/murmured/article/details/50596403 但感觉原作者的解释中存在一些错误,这里加了一些自己的理解 Given a sorted positive integer array nums and an integer n, 阅读全文

posted @ 2016-01-28 14:14 菱纱梦 阅读(436) 评论(0) 推荐(0)

Maximal Rectangle
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题意:在一个只有0、1的矩阵中找到一个面积最大的矩形,它内部所有的... 阅读全文

posted @ 2014-10-21 10:28 菱纱梦 阅读(178) 评论(0) 推荐(0)

Interleaving String
摘要:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = "aabcc",s2 = "dbbca", When s3 = "aadbbcbcac", ret 阅读全文

posted @ 2014-10-06 10:16 菱纱梦 阅读(179) 评论(0) 推荐(0)

Binary Tree Maximum Path Sum
摘要:Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example:Given the below binary tree, Return 6. 阅读全文

posted @ 2014-10-05 20:59 菱纱梦 阅读(159) 评论(0) 推荐(0)

Word Break
摘要:Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exampl... 阅读全文

posted @ 2014-10-04 09:54 菱纱梦 阅读(185) 评论(0) 推荐(0)

Add Binary <leetcode>
摘要:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".算法:模拟加法过程 1 class Solution { 2 public: 3 st... 阅读全文

posted @ 2014-09-30 10:42 菱纱梦 阅读(175) 评论(0) 推荐(0)

Construct Binary Tree from Preorder and Inorder Traversal<leetcode>
摘要:Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 题意:知道二叉树的前序遍历 阅读全文

posted @ 2014-09-29 22:00 菱纱梦 阅读(184) 评论(0) 推荐(0)

Triangle <leetcode>
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol... 阅读全文

posted @ 2014-09-29 21:26 菱纱梦 阅读(218) 评论(0) 推荐(0)

Jump Game <leetcode>
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文

posted @ 2014-09-18 21:02 菱纱梦 阅读(178) 评论(0) 推荐(0)

Search for a Range <leetcode>
摘要:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord... 阅读全文

posted @ 2014-09-17 12:04 菱纱梦 阅读(157) 评论(0) 推荐(0)

Subsets <leetcode>
摘要:Given a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not co... 阅读全文

posted @ 2014-09-17 10:44 菱纱梦 阅读(152) 评论(0) 推荐(0)

Unique Paths II <leetcode>
摘要:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i... 阅读全文

posted @ 2014-09-16 10:14 菱纱梦 阅读(220) 评论(0) 推荐(0)

Longest Consecutive Sequence <leetcode>
摘要: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-09-15 10:42 菱纱梦 阅读(375) 评论(0) 推荐(0)

Flatten Binary Tree to Linked List <leetcode>
摘要: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-09-13 21:26 菱纱梦 阅读(152) 评论(0) 推荐(0)

Sum Root to Leaf Numbers <leetcode>
摘要: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-09-09 20:25 菱纱梦 阅读(167) 评论(0) 推荐(0)

Combinations <leetcode>
摘要: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-09-09 19:48 菱纱梦 阅读(162) 评论(0) 推荐(0)

Populating Next Right Pointers in Each Node II <leetcode>
摘要:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil... 阅读全文

posted @ 2014-09-09 18:58 菱纱梦 阅读(146) 评论(0) 推荐(0)

Pascal's Triangle II <leetcode>
摘要: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-09-09 10:58 菱纱梦 阅读(122) 评论(0) 推荐(0)

Path Sum <leetcode>
摘要: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-09-09 10:27 菱纱梦 阅读(144) 评论(0) 推荐(0)

Remove Duplicates from Sorted Array II <leetcode>
摘要: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-09-09 09:53 菱纱梦 阅读(139) 评论(0) 推荐(0)

1 2 3 下一页