Problem Solving/LeetCode
Today's Challenge
fabichoi
2022. 11. 8. 23:45
https://leetcode.com/problems/make-the-string-great/
Make The String Great - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
여러가지 방법이 있는데, 투 포인터 쓰는게 제일 나을듯
나는 재귀 솔루션 참고함. (제일 짧아서 ㅋㅋㅋㅋㅋ)
class Solution:
def makeGood(self, s: str) -> str:
for i in range(len(s) - 1):
if abs(ord(s[i]) - ord(s[i+1])) == 32:
return self.makeGood(s[:i] + s[i + 2:])
return s
반응형