https://leetcode.com/problems/lexicographically-smallest-palindrome/description/
1 2 3 4 5 6 7 8 9 10 11 | class Solution: def makeSmallestPalindrome(self, s: str) -> str: s = list(s) for i in range(len(s)//2): if s[i] != s[-(i+1)]: if s[i] < s[-(i+1)]: s[-(i+1)] = s[i] else: s[i] = s[-(i+1)] return ''.join(s) | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2903. Find Indices With Index and Value Difference I (0) | 2023.12.28 |
---|---|
leetcode 2923. Find Champion I (0) | 2023.12.28 |
leetcode 2828. Check if a String Is an Acronym of Words (0) | 2023.12.28 |
백준 14913 등차수열에서 항 번호 찾기 (0) | 2023.12.28 |
leetcode 2928. Distribute Candies Among Children I (0) | 2023.12.27 |
댓글