Skip to content

Commit

Permalink
重构
Browse files Browse the repository at this point in the history
  • Loading branch information
soulmachine committed Oct 9, 2013
1 parent 8273935 commit a19ff0f
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 67 deletions.
Binary file modified C++/LeetCodet题解(C++版).pdf
Binary file not shown.
25 changes: 25 additions & 0 deletions C++/chapBruteforce.tex
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,31 @@ \subsubsection{代码}
};
\end{Code}

\begin{Code}
// LeetCode, Combinations
// use prev_permutation()
class Solution {
public:
vector<vector<int> > combine(int n, int k) {
vector<int> values(n);
iota(values.begin(), values.end(), 1);

vector<bool> select(n, false);
fill_n(select.begin(), k, true);

vector<vector<int> > result;
do{
vector<int> one(k);
for (int i = 0, index = 0; i < n; ++i)
if (select[i])
one[index++] = values[i];
result.push_back(one);
} while(prev_permutation(select.begin(), select.end()));
return result;
}
};
\end{Code}


\subsubsection{相关题目}
\begindot
Expand Down
Loading

0 comments on commit a19ff0f

Please sign in to comment.