Merged
Conversation
minji-go
reviewed
May 1, 2025
Comment on lines
+14
to
+18
| if (min > prices[i]) { | ||
| min = prices[i]; | ||
| continue; | ||
| } | ||
| max = Math.max(max, prices[i] - min); |
Contributor
There was a problem hiding this comment.
회고가 있는게 좋네요👍
저는 공간복잡도를 O(1)으로 만드는 부분이 어려웠던거 같아요!
최저가가 갱신되는 날은 판매하면 무조건 최대 이익이 아니다라는 관점에서 이해했는데,
이 부분이 이해하기 살짝 어렵게 느껴져서 Math.min()을 사용해서, 분기를 줄일 수도 있겠네요!
min = Math.min(min, prices[i]);
max = Math.max(max, prices[i] - min); continue가 없어서 max가 계산되어도, 값은 max 혹은 0이 될테니까요
Contributor
Author
There was a problem hiding this comment.
우와 생각하지 못했던 부분을 정성스럽게 피드백 해주셔서 감사합니다!
덕분에 분기를 줄여봤는데 더 깔끔해진 것 같아요 ㅎㅎ
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 하나 이상을 반드시 검토를 해주셔야 합니다!