Java | Counting Sort | O(n) time | Clean code
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n  public int[] sortArray(int[] nums) {\n    var map = new int[100001];\n\n    for (var n : nums)\n      map[n + 50000]++;\n\n    var k = 0;\n    for (var i = 0; i < 100001; i++)\n      for (var j = 0; j < map[i]; j++)\n        nums[k++] = i - 50000;\n\n    return nums;\n  }\n}\n```\nIf you like my solution, please upvote it!
['Array', 'Sorting', 'Java']