Java | Sorting Using Lambda Comparision Easy to Understand | Time O(k * n Log n) | Space O(1)
Time complexity : O(k * n Log n), assuming the sort() function uses a O(n Log n) sorting algorithm.\nSpace Complexity : O(1)\n\n\n\n\npublic String kthLargestNu
Time complexity : O(k * n Log n), assuming the sort() function uses a O(n Log n) sorting algorithm.\nSpace Complexity : O(1)\n\n\n``` \n\npublic String kthLargestNumber(String[] nums, int k) {\n        \n        Arrays.sort(nums, (s1, s2) ->{\n\t\t/* If length of s1 != s2, then return the difference of the length for comparision\n\t\telse  use compareTo function to compare values.*/\n            if(s1.length()!=s2.length())\n                return s1.length()-s2.length();\n            return s1.compareTo(s2);\n        });\n        \n        return nums[nums.length-k];\n    }\n\t\n\t```\n\t\n\t\n
[]