Skip to content

Commit 025474c

Browse files
committed
add 16.11 Solution for Java
1 parent e64fd11 commit 025474c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lcci/16.11.Diving Board/Solution.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public int[] divingBoard(int shorter, int longer, int k) {
3+
if (k == 0) {
4+
return new int[0];
5+
}
6+
if (longer == shorter) {
7+
return new int[]{longer * k};
8+
}
9+
int[] ans = new int[k + 1];
10+
for (int i = 0;i <= k;i++) {
11+
ans[i] = longer * i + shorter * (k - i);
12+
}
13+
return ans;
14+
}
15+
}

0 commit comments

Comments
 (0)