Skip to content

Commit c2323cf

Browse files
authored
Update maximum-number-of-weeks-for-which-you-can-work.cpp
1 parent 92a14a0 commit c2323cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

C++/maximum-number-of-weeks-for-which-you-can-work.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Solution {
66
long long numberOfWeeks(vector<int>& milestones) {
77
const int64_t total = accumulate(cbegin(milestones), cend(milestones), 0LL);
88
const int64_t max_num = *max_element(cbegin(milestones), cend(milestones));
9-
return min((total - max_num) + ((total - max_num) + 1), total);
9+
const int64_t other_total = total - max_num;
10+
return other_total + min(other_total + 1, max_num);
1011
}
1112
};

0 commit comments

Comments
 (0)