摘要: 可以想象有一个无限大的水罐,如果我们有两个杯子x和y,那么原来的问题等价于是否可以通过往里面注入或倒出水从而剩下z。 z =? m*x + n*y 如果等式成立,那么z%gcd(x,y) == 0。 阅读全文
posted @ 2017-01-05 14:00 lettuan 阅读(88) 评论(0) 推荐(0) 编辑
摘要: Numbers can be regarded as product of its factors. For example, Write a function that takes an integer n and return all possible combinations of its f 阅读全文
posted @ 2017-01-05 11:52 lettuan 阅读(182) 评论(0) 推荐(0) 编辑
摘要: Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. 阅读全文
posted @ 2017-01-05 05:13 lettuan 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be 阅读全文
posted @ 2017-01-05 04:26 lettuan 阅读(248) 评论(0) 推荐(0) 编辑
摘要: Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each num 阅读全文
posted @ 2017-01-05 04:11 lettuan 阅读(141) 评论(0) 推荐(0) 编辑
摘要: Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums 阅读全文
posted @ 2017-01-05 04:03 lettuan 阅读(421) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's 阅读全文
posted @ 2017-01-05 03:46 lettuan 阅读(103) 评论(0) 推荐(0) 编辑