C++ O(n) by using bucket sort and quickselect.
If I recall correctly, it won\'t work by applying nth_element directly on the strings. However, since the maximum length is limited to 100, we can use bucket so
If I recall correctly, it won\'t work by applying nth_element directly on the strings. However, since the maximum length is limited to 100, we can use bucket sort based on the length first. Apply nth_element after when we locate the target bucket. \n\nO(n) for bucket sort and another O(n) for quick select. \n\n```\nclass Solution {\npublic:\n    string kthLargestNumber(vector<string>& nums, int k) {\n        vector<vector<string>> dp( 101 );\n        for ( string & str : nums ) {\n            dp[str.size()].push_back(str);\n        }\n        for ( int len = 100; len > 0; --len ) {\n            if ( dp[len].size() >= k ) {\n                int index = dp[len].size() - k;\n                nth_element( dp[len].begin(), dp[len].begin() + index, dp[len].end() );\n                return dp[len][index];\n            } else {\n                k -= dp[len].size();\n            }\n        }\n        return "";\n    }\n};\n```
[]