[java] 보석 쇼핑#114
Open
Voyager003 wants to merge 1 commit into
Open
Conversation
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.
문제: 보석 쇼핑
언어: java
풀이 과정
투 포인터 문제입니다.
N 이 10만이상인 것을 확인하고, 투 포인터로 문제를 풀어야겠다고 생각했습니다.
그런데도 구현이 어려워, 다른 분의 블로그 글을 보고 풀이과정을 참고하여 구현을 했지만, 2시간 이상 시간이 걸렸네요..
최단 구간을 구하기 위해 보석 종류들을 다 모아도, start 를 옮겨줘야 합니다.
else if 문의 조건문을 처음에는 while(true) 바로 밑에 탈출 조건문으로 작성했다가, end 가 배열의 끝에 도달한 경우에도 start 가 오른쪽으로 옮겨서 답이 될 수도 있다는 것을 확인하고, 독단 if 문을 else if 문으로 조건문 위치를 옮겼습니다.
리뷰 요청 사항
투 포인터 문제는 항상 투 포인터로 푸는 것을 알아차리지만, 구현하는데에 있어서 항상 어려움을 겪는 것 같습니다.
혹시 다른 분들은 투 포인터 문제를 구현 및 풀이할 때 쉽게(?)하는 팁(?)들이 있을 지 해서 리뷰 요청 드립니다.