Merged
Conversation
JooKangsan
approved these changes
Feb 6, 2025
Collaborator
There was a problem hiding this comment.
슬라이딩 윈도우 이번에 찾아보면서 알았는데,
매번 새로운 배열을 생성하지 않고 기존 데이터를 업데이트 하는 방식이 확실히 효율적인거같네요...!
알고갑니다!
| } | ||
| return map | ||
| }, {}) | ||
| return can < max ? can : max |
Collaborator
There was a problem hiding this comment.
Math.min(can, max) 이 방법도 좋을거 같아요!
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[해시]
해시 문제를 풀며 리마인드했던 내용들과 얻은 인사이트를 정리했습니다.
해시를 활용해야 하는 상황들을 정리해봤습니다:
배열에서의 검색은 O(n)이 걸리지만, 해시는 O(1)로 접근 가능
ex)[오픈채팅방]문제에서 유저아이디로 닉네임 조회
출현 빈도나, 중복된 요소를 찾을 때 사용
연관된 데이터를 매핑할 때 (예: 이름과 점수 매핑, 키패드 문제 좌표 매핑)
그 외...
(map[key] || 0) + 1패턴이 유용했습니다.슬라이딩 윈도우
📌 알고리즘 개요
슬라이딩 윈도우는 배열이나 리스트의 일부 연속된 구간을 윈도우로 지정하고, 이 윈도우를 밀어가며 문제를 해결하는 알고리즘입니다. 투 포인터 알고리즘의 특수한 형태로, 구간의 크기가 고정되어 있다는 특징이 있습니다.
기본 구현 패턴
📌 푼 문제
📝 간단한 풀이 과정
완주하지 못한 선수
폰켓몬
추억 점수
할인 행사
오픈채팅방
키패드 누르기