Skip to content

Commit 4de23ad

Browse files
committed
feature DivingBoard
1 parent 207b106 commit 4de23ad

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.fancv.leetCode.arrays;
2+
3+
public class DivingBoard {
4+
5+
public static void main(String[] args) {
6+
7+
System.out.println(divingBoard(1, 1, 123));
8+
}
9+
10+
public static int[] divingBoard(int shorter, int longer, int k) {
11+
12+
13+
if (k == 0) {
14+
return new int[k];
15+
}
16+
if (shorter == longer) {
17+
return new int[]{shorter * k};
18+
}
19+
int[] r = new int[k + 1];
20+
for (int i = 0; i < k + 1; i++) {
21+
22+
r[i] = shorter * (k - i) + longer * i;
23+
}
24+
return r;
25+
26+
}
27+
}

0 commit comments

Comments
 (0)