mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-05 03:29:46 +08:00
clang-format and clang-tidy fixes for a152bf75
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
* @details
|
||||
* The partition problem, or number partitioning, is the task of deciding
|
||||
* whether a given multiset S of positive integers can be partitioned into two
|
||||
* subsets S1 and S2 such that the sum of the numbers in S1 equals the sum of the
|
||||
* numbers in S2. Although the partition problem is NP-complete, there is a
|
||||
* subsets S1 and S2 such that the sum of the numbers in S1 equals the sum of
|
||||
*the numbers in S2. Although the partition problem is NP-complete, there is a
|
||||
* pseudo-polynomial time dynamic programming solution, and there are heuristics
|
||||
* that solve the problem in many instances, either optimally or approximately.
|
||||
* For this reason, it has been called "the easiest hard problem".
|
||||
@@ -54,8 +54,9 @@ bool findPartiion(const std::vector<uint64_t> &arr, uint64_t size) {
|
||||
uint64_t sum = std::accumulate(arr.begin(), arr.end(),
|
||||
0); // Calculate sum of all elements
|
||||
|
||||
if (sum % 2 != 0)
|
||||
if (sum % 2 != 0) {
|
||||
return false; // if sum is odd, it cannot be divided into two equal sum
|
||||
}
|
||||
std::vector<bool> part;
|
||||
// bool part[sum / 2 + 1];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user