Created
July 9, 2021 14:27
-
-
Save dongwooklee96/b20836a1bd83047e5608c01c16e2fca3 to your computer and use it in GitHub Desktop.
2.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 문제 2.3: 문자열이 주어지고, 해당 문자열이 회문인지 아닌지를 확인하라 | |
| ## 제한 사항 | |
| 1. 문자열의 입력 true, 혹인 false를 반환한다. | |
| 2. 비어있는 문자열은 회문이라고 간주한다. | |
| """ | |
| from typing import List | |
| def isPalindrome(s: str) -> bool: | |
| i = 0 | |
| j = len(s) - 1 | |
| s = s.lower() | |
| while i < j: | |
| while i < j: | |
| if s[i].isalnum(): | |
| break | |
| i += 1 | |
| while i < j: | |
| if s[j].isalnum(): | |
| break | |
| j -= 1 | |
| if s[i] != s[j]: | |
| return False | |
| i += 1 | |
| j -= 1 | |
| return True | |
| if __name__ == "__main__": | |
| str = input() | |
| print(isPalindrome(str)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment