Skip to content

[robinyoon-dev] WEEK 05 Solutions#2495

Open
robinyoon-dev wants to merge 5 commits intoDaleStudy:mainfrom
robinyoon-dev:main
Open

[robinyoon-dev] WEEK 05 Solutions#2495
robinyoon-dev wants to merge 5 commits intoDaleStudy:mainfrom
robinyoon-dev:main

Conversation

@robinyoon-dev
Copy link
Copy Markdown
Contributor

@robinyoon-dev robinyoon-dev commented Apr 1, 2026

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@robinyoon-dev robinyoon-dev moved this from Solving to In Review in 리트코드 스터디 7기 Apr 4, 2026
@reeseo3o reeseo3o self-requested a review April 4, 2026 12:18
for (str of strs) {
let strCountString = getStrCountString(str);

let hasSameCountIndex = countArr.findIndex((item) => item === strCountString);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

findIndex로 매번 선형 탐색을 해서, 입력 문자열 수가 커지면 시간 복잡도가 많이 커질 것 같아요.
countArr 대신 ‎Map<string, string[]>처럼 ‎strCountString을 key로 바로 그룹 배열을 찾아갈 수 있게 두면, 여기 조회는 평균 O(1)에 처리돼서 전체 성능이 더 좋아질 것 같습니다!

const Z_ASCII = 'z'.charCodeAt(0);

let charCounts = Z_ASCII - A_ASCII + 1;
let charCountArr = new Array(charCounts).fill(0); //인덱스가 알파벳을 나타냄.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

각 문자열을 알파벳 카운트 배열로 바꿔서 비교하는 방식 자체가 정석적인 anagram 풀이 아이디어라서, 접근을 잘 잡으신 것 같아요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants