Skip to content

Commit 84b82d5

Browse files
authored
Update split-array-largest-sum.cpp
1 parent 4a9f60a commit 84b82d5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

C++/split-array-largest-sum.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Solution {
1111
}
1212

1313
while (left <= right) {
14-
int mid = left + (right - left) / 2;
14+
const auto mid = left + (right - left) / 2;
1515
if (canSplit(nums, m, mid)) {
1616
right = mid - 1;
1717
} else {
@@ -23,8 +23,7 @@ class Solution {
2323

2424
private:
2525
bool canSplit(vector<int>& nums, int m, int sum) {
26-
int cnt = 1;
27-
int curr_sum = 0;
26+
int cnt = 1, curr_sum = 0;
2827
for (const auto& num : nums) {
2928
curr_sum += num;
3029
if (curr_sum > sum) {

0 commit comments

Comments
 (0)