题目
太简单了,直接上代码:
class Solution { public: char nextGreatestLetter(vector<char>& letters, char target) { int n = letters.size(); int a[26] = {0}; for(int i = 0;i < n; ++i){ a[letters[i]-‘a‘]++; } for(int i = (target-‘a‘+1)%26; ; i++,i%=26){ if(a[i] > 0) return (char)(i + ‘a‘); } } };