LeetCode: Combination Sum II
摘要:
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Each number inCmay only be usedoncein the combination.这里数字不需要重复出现,所以使用dfs的时候,循环从上一次的下一个位置开始就可以了。但是这样会出现重复的结果。比如[1,2,3,1],因为第一个位置可以选两次1,所以可能会出现重复结果。所以这里排序是为了方便避免重复 阅读全文
posted @ 2014-02-03 14:03 longhorn 阅读(254) 评论(0) 推荐(0) 编辑