随笔分类 -  LeetCode

摘要:Subsets IIGiven a collection of integers that might contain duplicates,nums, return all possible subsets.Note:Elements in a subset must be in non-desc... 阅读全文
posted @ 2015-05-28 21:57 HelloWaston 阅读(192) 评论(0) 推荐(0)
摘要:Combination SumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thes... 阅读全文
posted @ 2015-05-25 22:12 HelloWaston 阅读(192) 评论(0) 推荐(0)
摘要:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie... 阅读全文
posted @ 2015-05-11 15:54 HelloWaston 阅读(140) 评论(0) 推荐(0)
摘要:用的是回溯法 1 class Solution { 2 public: 3 int INITIAL = -1000; 4 // 一维数组a[n]中,下标代表行号,对应里面存的值代表列号。比如a[2] = 4,说明2行4列(0行0列为最开始的行列号) 5 bool place(... 阅读全文
posted @ 2015-05-10 10:55 HelloWaston 阅读(165) 评论(0) 推荐(0)
摘要:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
posted @ 2015-05-06 20:19 HelloWaston 阅读(179) 评论(0) 推荐(0)
摘要:Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity... 阅读全文
posted @ 2015-05-06 19:43 HelloWaston 阅读(191) 评论(0) 推荐(0)