-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApps.java
More file actions
23 lines (19 loc) · 700 Bytes
/
Apps.java
File metadata and controls
23 lines (19 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.*;
public class Apps {
public static int[] findIndexes(int input[], int x, int index, ArrayList<Integer> ary) {
if (index == input.length) {
return ary.stream().mapToInt(Integer::intValue).toArray();
}
if (x == input[index]) {
ary.add(index);
}
return findIndexes(input, x, index + 1, ary);
}
public static void main(String[] args) {
int[] input = Genarate_Random.IntArray(1, 0, 1);
int[] ans = findIndexes(input, 1, 0, new ArrayList<>());
System.out.println(Arrays.toString(ans));
System.out.println(Arrays.stream(ans).max().orElse(-1));
this is a error
}
}