-
-
Notifications
You must be signed in to change notification settings - Fork 304
[devyulbae] WEEK 03 solutions #2114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@DaleStudy 리뷰해줘 |
|
좋은 진행과 다양한 문제 해결 시도를 보여주셔서 정말 잘하고 계세요! 몇 가지 개선할 점과 격려의 말씀을 드리자면:
계속해서 좋은 연습과 성장 이어가시길 바랍니다! |
haxr369
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devyulbae 님의 풀이를 보면서 내장함수를 잘 활용하시는 걸 보고
저도 내장함수를 활용해서 코드 길이를 줄여야겠단 생각이 들었습니다.
한 주 고생하셨고 다음 한주도 파이팅입니다!
| def isPalindrome(self, s: str) -> bool: | ||
| filtered_s = ''.join(char.lower() for char in s if char.isalnum()) | ||
| return filtered_s == filtered_s[::-1] | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 구현은 문자열을 여러 차례 순회하며 중간 결과를 생성하기 때문에 전체 처리 비용이 커집니다.
- 알파벳, 숫자만 추출해 새로운 문자열 생성
- 역순 문자열 생성(추가 메모리 사용)
- 두 문자열 비교
투포인터 방식을 적용하면 문자 검사, 정규화, 앞뒤 비교를 하나의 루프에서 처리할 수 있어 순회 비용을 단일 O(N)으로 줄일 수 있습니다. 별도 메모리를 사용하지 않으며, 불일치 시 즉시 종료할 수 있어 전체 런타임 측면에서도 더 효율적입니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 감사합니다! 한번 최적화해볼게요ㅎㅎ
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!