JAVA | BigInteger | Min heap (Priority Queue) ✅
Please Upvote :D\n---\n##### 1. Using BigInteger libary:\njava []\nimport java.math.BigInteger;\nclass Solution {\n    public String kthLargestNumber(String[] n
# Please Upvote :D\n---\n##### 1. Using BigInteger libary:\n``` java []\nimport java.math.BigInteger;\nclass Solution {\n    public String kthLargestNumber(String[] nums, int k) {\n        PriorityQueue<BigInteger> pq = new PriorityQueue<>();\n        for (String s : nums) {\n            pq.offer(new BigInteger(s));\n            if (pq.size() > k) {\n                pq.poll();\n            }\n        }\n\n        return pq.poll().toString();\n    }\n}\n\n// TC: O(n * logk), SC: O(n)\n```\n---\n##### 2. By custom comparison: \n``` java []\nclass Solution {\n    public String kthLargestNumber(String[] nums, int k) {\n        PriorityQueue<String> pq = new PriorityQueue<>(\n            (a, b) -> (a.length() == b.length())?\n            a.compareTo(b) : Integer.compare(a.length(), b.length())\n        );\n\n        for (String s : nums) {\n            pq.offer(s);\n            if (pq.size() > k) {\n                pq.poll();\n            }\n        }\n\n        return pq.poll();\n    }\n}\n\n// TC: O(n * logk), SC: O(n)\n```\n\n
['Array', 'String', 'Sorting', 'Heap (Priority Queue)', 'Java']