✅✅Faster || Easy To Understand || C++ Code
Approach 1 :- Using Sorting\n\n Time Complexity :- O(NlogN)\n\n Space Complexity :- O(1)\n\n\nclass Solution {\npublic:\n    \n    static bool compare(string& a
* ***Approach 1 :- Using Sorting***\n\n* ***Time Complexity :- O(NlogN)***\n\n* ***Space Complexity :- O(1)***\n\n```\nclass Solution {\npublic:\n    \n    static bool compare(string& a, string& b)\n    {\n        if(a.size() == b.size())\n            return a > b;\n        \n        // if size is different then sort on the basis of no. of digits\n        \n        else\n        {\n            return a.size() > b.size();\n        }\n    }\n    \n    string kthLargestNumber(vector<string>& nums, int k) {\n        \n        sort(nums.begin(), nums.end(), compare);\n        \n        return nums[k - 1];\n    }\n};\n```\n\n* ***Approach 2 :- Using Priority_queue***\n\n* ***Time Complexity :- O(N * logK)***\n\n* ***Space Complexity :- O(K)***\n\n```\nclass Solution {\npublic:\n    \n    // comparator function\n    \n    struct comparator\n    {\n        bool operator () (string& a, string& b)\n        {\n            if(a.size() == b.size())\n                return a > b;\n            else\n                return a.size() > b.size();\n        }\n    };\n    \n    string kthLargestNumber(vector<string>& nums, int k) {\n        \n        int n = nums.size();\n        \n        // declare a priority_queue in which the smaller no. will be at the top\n        \n        priority_queue<string, vector<string>, comparator> pq;\n        \n        for(int i = 0; i < n; i++)\n        {\n            if(i < k)\n            {\n                pq.push(nums[i]);\n            }\n            else\n            {\n                pq.push(nums[i]);\n                \n                pq.pop();\n            }\n        }\n        \n        return pq.top();\n    }\n};\n```
['C', 'Sorting', 'Heap (Priority Queue)', 'C++']