由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - if "(i > cur &&nums[i] == nums[i-1]) continue;
相关主题
这两道leetcode题有更好的答案吗?问一道关于字符串的面试题
一道amazon题那个24 game given 4 number用= - × /的题
A Question from leetcode, 求标准解法,本人解的太笨袅请教150上面binary的next permutation
大牛过来看道题PIE题: Phone number to words iterative 解法
amazon onsite 面经面试题总结(2) - Two/Three pointers
一个容易记忆的permutation算法经典递归题需要搞懂非递归算法吗?
String permunation question (CS)被这几个题目搞混了
请问大牛们leetcode上的Permutations II一道onsite面试题
相关话题的讨论汇总
话题: nums话题: cand话题: cur话题: continue话题: understand
进入JobHunting版参与讨论
1 (共1页)
f****e
发帖数: 923
1
这样为什么能去重呢, 看到3sum, 4sum, subset, 和permutation 里面很多这样写来去
重的?
我原来以为是因为 nums[i] 和 nums[i-1] 相同,
https://discuss.leetcode.com/topic/19845/java-solution-using-dfs-easy-
understand/16
cuyuan
Reputation: 3
For those who don't understand how to avoid duplicate by:
if "(i > cur && cand[i] == cand[i-1]) continue;
when we should skip a number? not just it's the same as previous number, but
also when it's previous number haven't been added!
i > cur means cand[i - 1] is not added to the path (you should know why if
you understand the algorithm), so if cand[i] == cand[i-1], then we shouldn't
add cand[i].
This tricky is very smart.
看到这回复,感觉不是这样的,有点晕了,求解惑
谢谢
R*****i
发帖数: 2126
2
http://huaren-it.com/thread/leetcode第40题-combination-sum-ii
1 (共1页)
进入JobHunting版参与讨论
相关主题
一道onsite面试题amazon onsite 面经
攒人品,yahoo电面面经一个容易记忆的permutation算法
请问一个java的问题(leetcode subsets一题)String permunation question (CS)
问个snapchat的面经题dfs优化的题请问大牛们leetcode上的Permutations II
这两道leetcode题有更好的答案吗?问一道关于字符串的面试题
一道amazon题那个24 game given 4 number用= - × /的题
A Question from leetcode, 求标准解法,本人解的太笨袅请教150上面binary的next permutation
大牛过来看道题PIE题: Phone number to words iterative 解法
相关话题的讨论汇总
话题: nums话题: cand话题: cur话题: continue话题: understand