Problem Solving/LeetCode
Today's Challenge
fabichoi
2022. 6. 8. 23:45
https://leetcode.com/problems/remove-palindromic-subsequences/
Remove Palindromic Subsequences - 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
Easy 난이도라 그런지 간단하게 풀 수 있다.
처음 봤을 땐 펠린드롬 구해야 하는 거 같았는데.. 문제를 더 자세히 보니 a, b 만 존재하는 형태라 펠린드롬 따위 구할 필요가 없다.
class Solution:
def removePalindromeSub(self, s: str) -> int:
return 1 if s == s[::-1] else 2
반응형