Skip to content

[1주차] 이유민 - 금 큐2, 프린터 큐 #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2025
Merged

[1주차] 이유민 - 금 큐2, 프린터 큐 #16

merged 2 commits into from
Apr 7, 2025

Conversation

Whatdoyumin
Copy link
Contributor

문제 풀이

  1. 큐 2
  • Queue를 활용하여 push, pop, size, empty, front, back 연산을 메서드로 분리해서 작성했습니다.
  • BufferedReader와 StringBuilder를 사용해 속도를 높였습니다.
  • push() 시에는 마지막으로 들어간 값을 따로 저장해 back() 명령 시 활용했습니다.
  • 각 명령에 대해 if-else로 구분하여 해당 메서드를 호출하고 결과를 StringBuilder에 추가했습니다.
  1. 프린터 큐
  • 각 문서를 int[]{index, priority} 형태로 큐에 저장하고, 현재보다 더 높은 중요도의 문서가 큐에 남아 있는지 검사했습니다.
  • 더 높은 중요도가 있다면 해당 문서를 다시 큐의 뒤로 보내고, 그렇지 않다면 순서를 뒤로 보냈습니다.
  • 궁금한 문서의 인덱스와 비교하여 몇 번째로 인쇄되는지를 판단하였습니다.
  • isHigherPriority() 메서드는 중요도 비교를 분리해 가독성을 높였습니다.
  • 이 문제도 BufferedReader와 StringBuilder를 사용해 효율적으로 처리했습니다.

@Whatdoyumin Whatdoyumin merged commit 28c25c5 into main Apr 7, 2025
@Whatdoyumin Whatdoyumin deleted the lym-1 branch April 7, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant