Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 438 Bytes

744.md

File metadata and controls

24 lines (15 loc) · 438 Bytes

Find Smallest Letter Greater Than Target

Description

link


Solution

  • See Code

Code 2

O(log(n))

class Solution:
    def nextGreatestLetter(self, letters: List[str], target: str) -> str:
        pos = bisect.bisect_right(letters, target)
        return letters[0] if pos == len(letters) else letters[pos]