We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e573f77 commit 2e6cfcfCopy full SHA for 2e6cfcf
Arrays/SortArray.java
@@ -0,0 +1,20 @@
1
+class SortArray {
2
+ public int[] sortArray(int[] nums) {
3
+ Map<Integer, Integer> map = new TreeMap<>();
4
+
5
+ for(int i = 0; i<nums.length; i++){
6
+ map.put(nums[i], map.getOrDefault(nums[i], 0)+1);
7
+ }
8
9
+ int pos = 0;
10
+ for(int key : map.keySet()){
11
+ int val = map.get(key);
12
+ for(int i = 0; i<val; i++){
13
+ nums[i+pos] = key;
14
15
+ pos = pos+val;
16
17
18
+ return nums;
19
20
+}
0 commit comments