随笔分类 -  leetcode

Decode Ways
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, determine t 阅读全文
posted @ 2016-06-07 15:54 怕忘记 阅读(138) 评论(0) 推荐(0)
Subsets II
摘要:Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplicate sub 阅读全文
posted @ 2016-06-07 15:53 怕忘记 阅读(129) 评论(0) 推荐(0)
Merge Sorted Array
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size tha 阅读全文
posted @ 2016-06-07 15:49 怕忘记 阅读(135) 评论(0) 推荐(0)
N-Queens
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all 阅读全文
posted @ 2016-06-07 15:04 怕忘记 阅读(169) 评论(0) 推荐(0)
Binary Tree Inorder Traversal
摘要:Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note... 阅读全文
posted @ 2015-10-22 21:57 怕忘记 阅读(229) 评论(0) 推荐(0)
Binary Tree Preorder Traversal
摘要:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3]. 1 ... 阅读全文
posted @ 2015-10-22 21:22 怕忘记 阅读(139) 评论(0) 推荐(0)
Binary Tree Postorder Traversal
摘要:Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1]. 1... 阅读全文
posted @ 2015-10-22 21:09 怕忘记 阅读(125) 评论(0) 推荐(0)
Remove Duplicates from Sorted List II
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-... 阅读全文
posted @ 2015-10-09 17:03 怕忘记 阅读(171) 评论(0) 推荐(0)
Remove Duplicates from Sorted Array II
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted arraynums=[1,1,1,2,2,3],Your function should re... 阅读全文
posted @ 2015-10-09 17:02 怕忘记 阅读(213) 评论(0) 推荐(0)
Subsets
摘要:Given a set of distinct integers,nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not... 阅读全文
posted @ 2015-10-09 16:58 怕忘记 阅读(170) 评论(0) 推荐(0)
Trapping Rain Water
摘要: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 @ 2015-10-09 16:57 怕忘记 阅读(109) 评论(0) 推荐(0)
Next Permutation
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl... 阅读全文
posted @ 2015-10-09 16:55 怕忘记 阅读(143) 评论(0) 推荐(0)
Scramble String
摘要:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation... 阅读全文
posted @ 2015-09-17 23:36 怕忘记 阅读(115) 评论(0) 推荐(0)
Partition List
摘要:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
posted @ 2015-09-17 23:34 怕忘记 阅读(120) 评论(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.int maximalRectangle(vector>& mat... 阅读全文
posted @ 2015-09-17 23:33 怕忘记 阅读(131) 评论(0) 推荐(0)
Largest Rectangle in Histogram
摘要:Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histog... 阅读全文
posted @ 2015-09-17 23:22 怕忘记 阅读(119) 评论(0) 推荐(0)
Implement strStr()
摘要:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The si... 阅读全文
posted @ 2015-09-17 22:24 怕忘记 阅读(118) 评论(0) 推荐(0)
Remove Element
摘要:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文
posted @ 2015-09-12 14:32 怕忘记 阅读(116) 评论(0) 推荐(0)
Remove Duplicates from Sorted Array
摘要:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a... 阅读全文
posted @ 2015-09-12 13:45 怕忘记 阅读(148) 评论(0) 推荐(0)
Reverse Nodes in k-Group
摘要:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2015-09-10 15:18 怕忘记 阅读(196) 评论(0) 推荐(0)