Skip to content

Commit 5677e6d

Browse files
committed
Runtime: 6 ms (Top 28.58%) | Memory: 43 MB (Top 43.79%)
1 parent 853e321 commit 5677e6d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 6 ms (Top 28.58%) | Memory: 43 MB (Top 43.79%)
12
class Solution {
23
public int[] relativeSortArray(int[] arr1, int[] arr2) {
34
Map <Integer, Integer> map = new TreeMap();
@@ -9,11 +10,11 @@ public int[] relativeSortArray(int[] arr1, int[] arr2) {
910
map.put(arr1[i], 1);
1011
}
1112
}
12-
13+
1314
int[] arr = new int [arr1.length];
1415
int ind = 0;
1516
for(int i = 0; i<arr2.length; i++){
16-
17+
1718
for(int j = 0; j<map.get(arr2[i]);j++){
1819
arr[ind] = arr2[i];
1920
ind++;
@@ -22,14 +23,14 @@ public int[] relativeSortArray(int[] arr1, int[] arr2) {
2223
}
2324

2425
for(int i: map.keySet()){
25-
26+
2627
for(int j = 0; j<map.get(i);j++){
2728
arr[ind] = i;
2829
ind++;
2930
}
3031

3132
}
32-
33+
3334
return arr;
3435
}
35-
}
36+
}

0 commit comments

Comments
 (0)