class Solution:
    def nextGreatestLetter(self, letters, target):
        """
        :type letters: List[str]
        :type target: str
        :rtype: str
        """
        nums=[0 for i in range(26)]
        for item in letters:
            nums[ord(item)-ord("a")]=1
        nums[ord(target)-ord("a")]=2
        i=0
        index=0
        while True:
            if index and nums[i]==1:
                return chr(ord("a")+i)
            if nums[i]==2:
                index=1
            i+=1
            i%=26
s=Solution()
letters = ["c", "f", "j"]
target = "j"
print(s.nextGreatestLetter(letters,target))
# 如果没有set这一步 time limited error



