partitionProblem {
54boolfindPartiion(
conststd::vector<uint64_t> &arr, uint64_t size) {
55uint64_t sum = std::accumulate(arr.begin(), arr.end(),
61std::vector<bool> part;
65 for(uint64_t it = 0; it <= sum / 2; ++it) {
66part.push_back(
false);
70 for(uint64_t it = 0; it < size; ++it) {
72 for(uint64_t it2 = sum / 2; it2 >= arr[it];
75 if(part[it2 - arr[it]] == 1 || it2 == arr[it]) {
90std::vector<uint64_t> arr = {{1, 3, 3, 2, 3, 2}};
91uint64_t n = arr.size();
92 boolexpected_result =
true;
93 boolderived_result = dp::partitionProblem::findPartiion(arr, n);
94std::cout <<
"1st test: ";
95assert(expected_result == derived_result);
96std::cout <<
"Passed!"<< std::endl;
static void test()
Self-test implementations.
int main()
Main function.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4