상위 150개 인터뷰쉬움

유효한 회문

'Valid Palindrome' 문제에 대한 자세한 가이드 및 Python 구현입니다.

문제 설명

쉬움

모든 대문자를 소문자로 변환하고 영숫자가 아닌 문자를 모두 제거한 후 앞뒤로 동일하게 읽는 경우 구문은 회문입니다. 영숫자 문자에는 문자와 숫자가 포함됩니다.

문자열 s이 주어지면 회문이면 True을 반환하고 그렇지 않으면 False을 반환합니다.

isPalindrome(s: str) -> bool 함수를 작성하세요.

제약
  • 1 <= len(s) <= 2 * 10^5
  • s consists only of printable ASCII characters

Example 1
Input
s = "A man, a plan, a canal: Panama"
Output
True
Explanation

After removing non-alphanumeric characters and converting to lowercase: "amanaplanacanalpanama", which is a palindrome.

Example 2
Input
s = "race a car"
Output
False
Explanation

After processing: "raceacar" is not a palindrome.

Example 3
Input
s = " "
Output
True
Explanation

After removing non-alphanumeric characters, s is an empty string. An empty string is a palindrome by definition.

Need a Hint?
세트나 힙과 같은 두 포인터 관련 데이터 구조를 사용하는 것을 고려해보세요.
Edge Cases to Watch
  • 빈 입력 구조
  • 단일 요소 입력
  • 큰 수치 범위

해결할 준비가 되셨나요?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

편집기에서 열기
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

권장 Python 리소스

관련 대화형 튜토리얼, 치트 시트, 코드 비교를 통해 지식을 확장하세요.