We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ab43f9e + c0deccb commit a34c139Copy full SHA for a34c139
2 files changed
leetcode/Study Plan/3432. 统计元素和差值为偶数的分区方案/1.cpp
@@ -1,5 +1,13 @@
1
+#include <vector>
2
+#include <numeric>
3
class Solution {
4
public:
5
+ /**
6
+ * @brief Compute a partition-count value determined by whether the sum of `nums` is odd or even.
7
+ *
8
+ * @param nums Input vector of integers whose elements are summed.
9
+ * @return int `0` if the total sum of `nums` is odd; otherwise `nums.size() - 1` (which is `-1` for an empty vector).
10
+ */
11
int countPartitions(vector<int>& nums) {
12
int sum = reduce(nums.begin(),nums.end());
13
return sum % 2 ? 0 : nums.size() - 1;
luogu/入门/P1035/tempCodeRunnerFile.cpp
0 commit comments