File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed
maximum-number-of-weeks-for-which-you-can-work Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -2612,4 +2612,6 @@ https://leetcode.cn/problems/equal-row-and-column-pairs
2612
2612
2613
2613
https://leetcode.cn/problems/count-vowel-strings-in-ranges
2614
2614
2615
+ https://leetcode.cn/problems/maximum-number-of-weeks-for-which-you-can-work
2616
+
2615
2617
</details >
Original file line number Diff line number Diff line change 5
5
<sourceFolder url =" file://$MODULE_DIR$/count-vowel-strings-in-ranges" isTestSource =" false" packagePrefix =" com.github.masx200.leetcode_test.count_vowel_strings_in_ranges" />
6
6
<sourceFolder url =" file://$MODULE_DIR$/test" isTestSource =" true" packagePrefix =" com.github.masx200.leetcode_test" />
7
7
<sourceFolder url =" file://$MODULE_DIR$/zigzag-iterator" isTestSource =" false" packagePrefix =" com.github.masx200.leetcode_test.zigzag_iterator" />
8
+ <sourceFolder url =" file://$MODULE_DIR$/maximum-number-of-weeks-for-which-you-can-work" isTestSource =" false" packagePrefix =" com.github.masx200.leetcode_test.maximum_number_of_weeks_for_which_you_can_work" />
8
9
<excludeFolder url =" file://$MODULE_DIR$/target" />
9
10
</content >
10
11
</component >
Original file line number Diff line number Diff line change
1
+ package com.github.masx200.leetcode_test.maximum_number_of_weeks_for_which_you_can_work
2
+
3
+ class Solution {
4
+ fun numberOfWeeks (milestones : IntArray ): Long {
5
+ var sum: Long = 0
6
+ var max: Long = 0
7
+ milestones.forEach {
8
+ sum + = it.toLong()
9
+ max = Math .max(max, it.toLong())
10
+ }
11
+ return if (max * 2 > sum) (sum - max) * 2 + 1 else sum
12
+
13
+
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments