PriorityQueue 3

99클럽 코테 스터디 38일차 TIL Seat Reservation Manager feat.Heap

https://leetcode.com/problems/seat-reservation-manager/   heap    1.  문제 및 접근    1845. Seat Reservation Manager 3개의 메서드1. SeatManager(int n)의 자리 초기화2. reserve 예약하면 작은 수부터 예약하고, 작은 수 반환3. unreserve 들어온 자석 번호 취소 void O(n)으로 푸니 마지막에 시간초과 걸림  Constraints:1 1 For each call to reserve, it is guaranteed that there will be at least one unreserved seat.For each call to unreserve, it is guaranteed that se..

알고리즘 2024.06.26

99클럽 코테 스터디 32일차 TIL Top K Frequent Elements feat. CountingSort

https://leetcode.com/problems/top-k-frequent-elements/description/   priorityQueuemapmap.mergecounting sort    1.  문제 및 접근   347. Top K Frequent Elementsmap으로 관리31일차 문제와 너무 유사priorityQueue로 우선순위를 빈도의 내림차순으로 주고 K개만큼 뽑기++counting sort 방식 추가 문제가 이해하기 힘들어서 내 영어 실력의 문제인가 했지만, 댓글들을 보니 전세계인들이 화나있다불친절한 리트코드..   Constraints:1 -10^4 k is in the range [1, the number of unique elements in the array].It is g..

알고리즘 2024.06.20

99클럽 코테 스터디 31일차 TIL Sort Characters By Frequency feat. Comparator vs Comparable

https://leetcode.com/problems/sort-characters-by-frequency/submissions/1293844763/  getOrDefualtpriorityQueuemaxHeapmapEntry   1.  문제 및 접근   주어진 s를 나타나는 빈도수에 대해 내림차순으로 반환같은 수의 빈도라면 위치 상관 x , 붙어있어야 함 최대 50만 들어오고, 소문자 대문자 둘다 들어옴 문자를 돌면서 숫자를 세기 ? 그 후 객체로 비교 해서 정렬compatormap에 저장하고, 그 빈도수로 찾으면 더 편할듯 ?map에 키로 그 char 넣고, value로 빈도를 넣음밸류 값으로 내림순 정렬 후 그 키 그대로 반환 map.entry와 우선순위 큐 둘다 써 봐야겠다..  Constraints..

알고리즘 2024.06.20