Skip to content

Conversation

taekwon-dev
Copy link
Contributor

@taekwon-dev taekwon-dev commented Sep 5, 2024

답안 제출 문제

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@obzva obzva self-requested a review September 6, 2024 14:51
@taekwon-dev taekwon-dev marked this pull request as ready for review September 7, 2024 00:57
@taekwon-dev taekwon-dev requested a review from a team as a code owner September 7, 2024 00:57
Copy link
Contributor

@HC-kang HC-kang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요 @taekwon-dev 님, 4주차도 고생 많으셨습니다!

public boolean isPalindrome(String s) {
s = s.replaceAll("[^a-zA-Z0-9]", "").toLowerCase();

char[] c = s.toCharArray();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 자바를 잘 몰라서 궁금한 부분인데, toCharArray()로 변경 없이 string상태로 인덱스 접근하는 방식은 불가능할까요?
명시적인 시간복잡도 감소는 없겠지만, 루프를 한 싸이클 줄일 수 있을 것 같아서요!

Copy link
Contributor

@jaejeong1 jaejeong1 Sep 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taekwon-dev 위 의견에 덧붙이자면, toCharArray() 변경하지 않고 바로 인덱스 접근 시 공간복잡도를 N -> 1로 줄일 수 있는 효과가 있을 것으로 보입니다.
@HC-kang 말씀주신 방법은 자바에서 s.charAt(index) 와 같은 방식으로 가능합니다 :)

@taekwon-dev taekwon-dev merged commit 5120c30 into DaleStudy:main Sep 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants