[C++] | Simple | Explained with Diagram
NOTE \n1. Sorting the strings won\'t work here because "21" will come before "121" \n2. We can\'t convert the strings into integer because the length of the str
### NOTE \n1. Sorting the strings won\'t work here because "21" will come before "121" \n2. We can\'t convert the strings into integer because the length of the string is quite large and it will overflow\n\n### Logic : \n\n1. We are going to make use of a comparator function and will compare the strings\n\n\n2. `CASE 1 :` If the both the strings have same length, then we just need to return at the first character which becomes different\n\n![image](https://assets.leetcode.com/users/images/380b2f87-907b-4bd1-9695-5607c39033c8_1630209782.6400795.png)\n\n3. `CASE 2 : ` If the length is unequal, we need to reuturn the larger string before the smaller string \n\n![image](https://assets.leetcode.com/users/images/e52e8b4e-71e6-4783-8416-6b20a656b05e_1630209755.1183207.png)\n\n<br>\n\n`Please upvote if you like the approach and explanation`\n\n<br>\n\nCode : \n\n```cpp\n/**\n * @author      : archit\n * @GitHub      : archit-1997\n * @Email       : architsingh456@gmail.com\n * @file        : b.cpp\n * @created     : Sunday Aug 29, 2021 08:21:17 IST\n */\n\n#include <bits/stdc++.h>\nusing namespace std;\n\nbool compare(const string &a,const string &b){\n    int na=a.size(),nb=b.size();\n    if(na==nb){\n\t//if the size of both strings is same\n        for(int i=0;i<na;i++){\n\t\t//if the character in the first string is greater than the second one\n            if(a[i]>b[i])\n                return true;\n\t\t\t//if charcter in the second string is greater\n            if(a[i]<b[i])\n                return false;\n        }\n\t\t//if both are same, preserver the order\n        return false;\n    }\n\t//return the string with larger size\n    return a.size()>b.size();\n}\n\nclass Solution {\npublic:\n    string kthLargestNumber(vector<string>& nums, int k) {\n        sort(nums.begin(),nums.end(),compare);\n        return nums[k-1];\n    }\n};\n\n```\n\n
[]