- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1365.java
23 lines (21 loc) · 672 Bytes
/
_1365.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
packagecom.fishercoder.solutions.secondthousand;
importjava.util.ArrayList;
importjava.util.Arrays;
importjava.util.List;
publicclass_1365 {
publicstaticclassSolution1 {
publicint[] smallerNumbersThanCurrent(int[] nums) {
int[] result = newint[nums.length];
int[] tmp = Arrays.copyOf(nums, nums.length);
Arrays.sort(tmp);
List<Integer> list = newArrayList<>();
for (inti : tmp) {
list.add(i);
}
for (inti = 0; i < nums.length; i++) {
result[i] = list.indexOf(nums[i]);
}
returnresult;
}
}
}