### 16.11. 跳水板

shorter = 1
longer = 2
k = 3

0 < shorter <= longer
0 <= k <= 100000

### 解题思路

``````我的方法比较粗暴，例如题目所给的实例题：
shorter = 1
longer = 2
k = 3
输出： {
3,4,5,6}
k = 3有分配给shorter和longer的情况有哪几种？

0 3（两种）--->shorter = 0,longer = 3或shorter = 3,longer = 0
1 2（两种）--->shorter = 1,longer = 2或shorter = 2,longer = 1
2 1（两种）--->shorter = 2,longer = 1或shorter = 1,longer = 2
3 0（两种）--->shorter = 3,longer = 0或shorter = 0,longer = 3

6，3，5，4，4，5，6，3}去重后就是 {
3,4,5,6}
``````

### 代码

``````class Solution {

public int[] divingBoard(int shorter, int longer, int k) {

int i = 0,j=0;
//如果 = 0时返回 [],  new int[0]返回的就是首地址[]
if(k == 0){

return new int[0];
}
//数组，包含重复
ArrayList<Integer> list = new ArrayList();
for(i = 0,j=k; i<=k && j>=0; i++,j--){

}
//去重后
Set<Integer> set = new HashSet(list);
//存入Object数组
Object[] arrays = set.toArray();
//排序
Arrays.sort(arrays);
//Object-->Integer
Integer[] integers = new Integer[arrays.length];
for ( i = 0; i < arrays.length; i++) {

integers[i] = Integer.parseInt(arrays[i].toString());
}
//Integer--->int
int result[] = new int[integers.length];
for( i = 0; i<integers.length; i++){

result[i] = integers[i];
}

return result;

}
}
``````