由买买提看人间百态

topics

全部话题 - 话题: retsize
(共0页)
a***e
发帖数: 413
1
来自主题: JobHunting版 - Leetcode上subsets-ii的疑问
为什么要j>=prevSize?总是不理解这一点,多谢!
if (i==0||S[i]!=S[i-1]||j>=prevSize)
https://oj.leetcode.com/problems/subsets-ii/
Given a collection of integers that might contain duplicates, S, return all
possible subsets.
Note:
vector > subsetsWithDup(vector &S) {
vector> ret;
int n = S.size();
if (n==0) return ret;

sort(S.begin(),S.end());
ret.resize(1);
int prevSize = 0;
for (int i=0; i {
... 阅读全帖
(共0页)