[moonjonghoo] Week 05 Solutions#1400
Merged
Moonjonghoo merged 3 commits intoDaleStudy:mainfrom May 3, 2025
Merged
Conversation
hi-rachel
approved these changes
May 3, 2025
Contributor
hi-rachel
left a comment
There was a problem hiding this comment.
한 주 고생많으셨습니다 :) 저와 다르게 접근한 풀이들도 보면서 배우고 갑니다!
| let maxProfit = 0; | ||
| let currentProfit = 0; | ||
| for (let i = 1; i < prices.length; i++) { | ||
| let diff = prices[i] - prices[i - 1]; |
Contributor
There was a problem hiding this comment.
어제와 오늘의 가격 차이를 계산하고 그 합이 최대가 되는 구간을 찾는 로직이군여!
| if (!hashMap.has(key)) { | ||
| hashMap.set(key, [strs[i]]); | ||
| } else { | ||
| hashMap.set(key, [...hashMap.get(key), strs[i]]); |
Contributor
There was a problem hiding this comment.
hashMap.get(key).push(strs[i]);
을 활용하면 새 배열을 생성하지 않고 바로 push 할 수 있습니다.
Contributor
Author
There was a problem hiding this comment.
아 맞습니다. 반영을 못했네요 ㅠㅠ
| hashMap.set(key, [...hashMap.get(key), strs[i]]); | ||
| } | ||
| } | ||
| let answer = []; |
Contributor
There was a problem hiding this comment.
Array.from(hashMap.values()) 를 활용할 수도 있습니다.
| const memo = new Map(); // 실패/성공 여부 기억 | ||
| const wordSet = new Set(wordDict); // lookup 최적화 | ||
|
|
||
| function canBreak(sub) { |
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.
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!