https://leetcode.com/problems/find-smallest-letter-greater-than-target/description/
Find Smallest Letter Greater Than Target - LeetCode
Can you solve this real interview question? Find Smallest Letter Greater Than Target - You are given an array of characters letters that is sorted in non-decreasing order, and a character target. There are at least two different characters in letters. Retu
leetcode.com
1
2
3
4
5
6
7
8
9
|
class Solution:
def nextGreatestLetter(self, letters: List[str], target: str) -> str:
chk = 0
for alphabet in letters:
if target < alphabet:
return alphabet
chk = 1
if chk == 0:
return letters[0]
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 13. Roman to Integer (1) | 2023.06.19 |
---|---|
leetcode 27. Remove Element (0) | 2023.06.19 |
백준 28074 모비스 (0) | 2023.06.08 |
백준 28097 모범생 포닉스 (0) | 2023.06.08 |
백준 27890 특별한 작은 분수 (0) | 2023.06.08 |
댓글