Skip to content

Commit bf7f607

Browse files
committed
update
1 parent 846e333 commit bf7f607

File tree

3 files changed

+63
-31
lines changed

3 files changed

+63
-31
lines changed

data/progress.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
20241231: 769,817
1+
20241231: 769,817,855(again)
22
20241229: 498(again),934
3-
20241228: 379,173,855(todo)
3+
20241228: 379,173
44
20241227: 079,212(todo),362,849
55
20241222: 369,311
66
20241221: 370

data/to_review.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
2025-02-24 -> ['769,817']
1+
2025-02-24 -> ['769,817,855(again)']
22
2025-02-22 -> ['498(again),934']
3-
2025-02-21 -> ['379,173,855(todo)']
3+
2025-02-21 -> ['379,173']
44
2025-02-20 -> ['079,212(todo),362,849']
55
2025-02-15 -> ['369,311']
66
2025-02-14 -> ['370']
77
2025-02-13 -> ['815,871,593,1109']
88
2025-02-07 -> ['560,523']
9-
2025-02-03 -> ['769,817']
9+
2025-02-03 -> ['769,817,855(again)']
1010
2025-02-01 -> ['498(again),934', '304,853,325']
11-
2025-01-31 -> ['379,173,855(todo)']
11+
2025-01-31 -> ['379,173']
1212
2025-01-30 -> ['079,212(todo),362,849']
1313
2025-01-26 -> ['370(todo)']
1414
2025-01-25 -> ['369,311']
1515
2025-01-24 -> ['370', '34,767']
1616
2025-01-23 -> ['815,871,593,1109']
17-
2025-01-21 -> ['769,817']
17+
2025-01-21 -> ['769,817,855(again)']
1818
2025-01-20 -> ['722,380']
1919
2025-01-19 -> ['498(again),934', '33,81']
20-
2025-01-18 -> ['379,173,855(todo)']
20+
2025-01-18 -> ['379,173']
2121
2025-01-17 -> ['079,212(todo),362,849', '560,523', '253']
2222
2025-01-16 -> ['776,31']
2323
2025-01-15 -> ['004(todo),34(todo),162(todo),275(todo)']
2424
2025-01-14 -> ['986(todo),1229(todo),1868(todo),80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)']
25-
2025-01-13 -> ['769,817']
25+
2025-01-13 -> ['769,817,855(again)']
2626
2025-01-12 -> ['369,311']
2727
2025-01-11 -> ['498(again),934', '370', '304,853,325', '394']
28-
2025-01-10 -> ['379,173,855(todo)', '815,871,593,1109', '833,950']
28+
2025-01-10 -> ['379,173', '815,871,593,1109', '833,950']
2929
2025-01-09 -> ['079,212(todo),362,849']
30-
2025-01-08 -> ['769,817']
30+
2025-01-08 -> ['769,817,855(again)']
3131
2025-01-06 -> ['498(again),934']
32-
2025-01-05 -> ['769,817', '379,173,855(todo)', '370(todo)']
32+
2025-01-05 -> ['769,817,855(again)', '379,173', '370(todo)']
3333
2025-01-04 -> ['079,212(todo),362,849', '369,311', '560,523', '53,210,207']
34-
2025-01-03 -> ['769,817', '498(again),934', '370', '34,767', '444']
35-
2025-01-02 -> ['769,817', '379,173,855(todo)', '815,871,593,1109', '1188,130,855(again)']
36-
2025-01-01 -> ['769,817', '498(again),934', '079,212(todo),362,849']
37-
2024-12-31 -> ['498(again),934', '379,173,855(todo)']
38-
2024-12-30 -> ['498(again),934', '379,173,855(todo)', '079,212(todo),362,849', '369,311', '722,380']
39-
2024-12-29 -> ['379,173,855(todo)', '079,212(todo),362,849', '370', '304,853,325', '33,81']
34+
2025-01-03 -> ['769,817,855(again)', '498(again),934', '370', '34,767', '444']
35+
2025-01-02 -> ['769,817,855(again)', '379,173', '815,871,593,1109', '1188,130,855(again)']
36+
2025-01-01 -> ['769,817,855(again)', '498(again),934', '079,212(todo),362,849']
37+
2024-12-31 -> ['498(again),934', '379,173']
38+
2024-12-30 -> ['498(again),934', '379,173', '079,212(todo),362,849', '369,311', '722,380']
39+
2024-12-29 -> ['379,173', '079,212(todo),362,849', '370', '304,853,325', '33,81']
4040
2024-12-28 -> ['079,212(todo),362,849', '815,871,593,1109', '900']
4141
2024-12-27 -> ['369,311', '560,523', '253', '26,27', '802,1197,26']
4242
2024-12-26 -> ['370', '776,31']

leetcode_java/src/main/java/dev/workspace6.java

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -820,43 +820,75 @@ public int maxDistToClosest(int[] seats) {
820820

821821
// LC 855
822822
// https://leetcode.com/problems/exam-room/description/
823-
// 5.31 PM - 5.50 pm
823+
// 5.21 - 5.40 pm
824824
/**
825825
* Your ExamRoom object will be instantiated and called as such:
826826
* ExamRoom obj = new ExamRoom(n);
827827
* int param_1 = obj.seat();
828828
* obj.leave(p);
829829
*/
830830
/**
831-
* IDEA:
831+
* IDEA: PQ (min queue)
832832
*
833833
*
834834
*/
835835
class ExamRoom {
836836

837+
PriorityQueue<Integer> pq;
837838
int seated;
838-
List<Integer> seats;
839839

840840
public ExamRoom(int n) {
841-
this.seated = 0;
842-
this.seats = new ArrayList<>();
843-
// ?? optimize
844-
for(int i = 0; i < n; i++){
845-
this.seats.add(0);
846-
}
841+
pq = new PriorityQueue<>(); // ??
842+
seated = 0;
847843
}
848844

849845
public int seat() {
850-
if (this.seated == 0){
851-
//this.seats. = 1;
846+
if(this.seated == 0){
847+
this.pq.add(0);
848+
return 0;
852849
}
853-
return 0;
850+
//pq.poll();
851+
return pq.peek(); // ???
854852
}
855853

856854
public void leave(int p) {
857-
855+
List<Integer> tmp = new ArrayList<>();
856+
while (this.pq.peek() != p){
857+
this.pq.poll();
858+
}
859+
//return this.pq.poll();
860+
this.pq.poll();
861+
// add element back to PQ
862+
for(int x : tmp){
863+
this.pq.add(x);
864+
}
858865
}
859866
}
867+
// class ExamRoom {
868+
//
869+
// int seated;
870+
// List<Integer> seats;
871+
//
872+
// public ExamRoom(int n) {
873+
// this.seated = 0;
874+
// this.seats = new ArrayList<>();
875+
// // ?? optimize
876+
// for(int i = 0; i < n; i++){
877+
// this.seats.add(0);
878+
// }
879+
// }
880+
//
881+
// public int seat() {
882+
// if (this.seated == 0){
883+
// //this.seats. = 1;
884+
// }
885+
// return 0;
886+
// }
887+
//
888+
// public void leave(int p) {
889+
//
890+
// }
891+
// }
860892

861893
// LC 379
862894
// https://leetcode.ca/all/379.html

0 commit comments

Comments
 (0)