diff --git a/data/progress.md b/data/progress.md index 4aafba1c..d9ef6a2e 100644 --- a/data/progress.md +++ b/data/progress.md @@ -1,5 +1,9 @@ # Progress +# 2024-11-17 +- https://github.com/wisdompeak/LeetCode/tree/master?tab=readme-ov-file#two-pointers + - (Two pointers for two sequences) + # 2024-11-17 - https://github.com/yennanliu/CS_basics/blob/master/doc/Leetcode_company_frequency-master/Google%206months-%20LeetCode.pdf diff --git a/data/progress.txt b/data/progress.txt index 923dfc15..fadf7667 100644 --- a/data/progress.txt +++ b/data/progress.txt @@ -1,6 +1,6 @@ +20241120: 986,80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo) 20241117: 394 20241116: 833,950 -20241114: 80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo) 20241110: 53,210,207 20241109: 444 20241108: 1188,130,855(again) diff --git a/data/to_review.txt b/data/to_review.txt index 2d2a994a..a076909a 100644 --- a/data/to_review.txt +++ b/data/to_review.txt @@ -1,38 +1,41 @@ +2025-01-14 -> ['986,80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)'] 2025-01-11 -> ['394'] 2025-01-10 -> ['833,950'] -2025-01-08 -> ['80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)'] 2025-01-04 -> ['53,210,207'] 2025-01-03 -> ['444'] 2025-01-02 -> ['1188,130,855(again)'] 2024-12-28 -> ['900'] 2024-12-27 -> ['26,27', '802,1197,26'] +2024-12-24 -> ['986,80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)'] 2024-12-21 -> ['394', '855,846'] 2024-12-20 -> ['833,950', '932'] -2024-12-18 -> ['80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '951,792'] +2024-12-18 -> ['951,792'] 2024-12-14 -> ['53,210,207', '163,1048'] 2024-12-13 -> ['444', '298,729'] 2024-12-12 -> ['1188,130,855(again)', '1146'] +2024-12-11 -> ['986,80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)'] 2024-12-08 -> ['394', '737'] 2024-12-07 -> ['833,950', '900', '686,734,737'] 2024-12-06 -> ['26,27', '802,1197,26', '353'] -2024-12-05 -> ['80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '528,334'] -2024-12-03 -> ['1145'] +2024-12-05 -> ['528,334'] +2024-12-03 -> ['986,80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '1145'] 2024-12-01 -> ['53,210,207'] 2024-11-30 -> ['394', '444', '855,846', '1145,1219'] 2024-11-29 -> ['833,950', '1188,130,855(again)', '932'] -2024-11-27 -> ['80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '951,792', '524,221,889'] +2024-11-28 -> ['986,80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)'] +2024-11-27 -> ['951,792', '524,221,889'] 2024-11-26 -> ['743,889'] -2024-11-25 -> ['394', '837'] +2024-11-25 -> ['986,80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '394', '837'] 2024-11-24 -> ['833,950', '900'] -2024-11-23 -> ['53,210,207', '26,27', '802,1197,26', '163,1048', '981'] -2024-11-22 -> ['394', '80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '444', '298,729', '1087'] -2024-11-21 -> ['833,950', '1188,130,855(again)', '1146'] +2024-11-23 -> ['986,80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '53,210,207', '26,27', '802,1197,26', '163,1048', '981'] +2024-11-22 -> ['986,80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '394', '444', '298,729', '1087'] +2024-11-21 -> ['986,80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '833,950', '1188,130,855(again)', '1146'] 2024-11-20 -> ['394', '939'] -2024-11-19 -> ['394', '833,950', '80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)'] +2024-11-19 -> ['394', '833,950'] 2024-11-18 -> ['394', '833,950', '53,210,207', '430'] -2024-11-17 -> ['833,950', '80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '444', '855,846', '737', '363'] -2024-11-16 -> ['80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '1188,130,855(again)', '900', '932', '686,734,737', '1032,844,1011'] -2024-11-15 -> ['80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)', '53,210,207', '26,27', '802,1197,26', '353', '947'] +2024-11-17 -> ['833,950', '444', '855,846', '737', '363'] +2024-11-16 -> ['1188,130,855(again)', '900', '932', '686,734,737', '1032,844,1011'] +2024-11-15 -> ['53,210,207', '26,27', '802,1197,26', '353', '947'] 2024-11-14 -> ['444', '951,792', '528,334'] 2024-11-13 -> ['53,210,207', '1188,130,855(again)'] 2024-11-12 -> ['53,210,207', '444', '1145', '753'] diff --git a/leetcode_java/src/main/java/dev/workspace5.java b/leetcode_java/src/main/java/dev/workspace5.java index 05c6084d..ff7c1499 100644 --- a/leetcode_java/src/main/java/dev/workspace5.java +++ b/leetcode_java/src/main/java/dev/workspace5.java @@ -2088,7 +2088,7 @@ public int[] beautifulArray(int n) { // LC 855 // https://leetcode.com/problems/exam-room/ - // 4.28 pm - 4.40 pm + // 6.53 - 7.15 am /** * ep 1: * @@ -2112,33 +2112,79 @@ public int[] beautifulArray(int n) { * */ class ExamRoom { - // attr + int[] seats; - PriorityQueue pq; + int seated; public ExamRoom(int n) { - this.seats = new int[n]; - this.pq = new PriorityQueue(); + seats = new int[n]; // init val ?? + seated = 0; } public int seat() { - // if not one seated, select the 0 idx seat - if (this.pq.isEmpty()){ - this.seats[0] = 0; + //return 0; + if (seated == 0){ + seats[0] = 1; + seated += 1; return 0; } - // TODO : fix - return 0; + // get "to compare" seat + int idx = -1; + for (int j = 0; j < seats.length; j++){ + // get distance + //int dis = 1; + if (seats[j] == 0){ + idx = j; + break; + } + } + + int toPutIdx = -1; + // find "maximizes the distance to the closest person" + for (int i = seats.length; i > 0; i--){ + if (seats[i] != 0){ + toPutIdx = i; + break; + } + } + return toPutIdx; // ??? } public void leave(int p) { - - this.seats[p] = 0; + seats[p] = 0; + seated -= 1; } - } +// class ExamRoom { +// // attr +// int[] seats; +// PriorityQueue pq; +// +// public ExamRoom(int n) { +// this.seats = new int[n]; +// this.pq = new PriorityQueue(); +// } +// +// public int seat() { +// // if not one seated, select the 0 idx seat +// if (this.pq.isEmpty()){ +// this.seats[0] = 0; +// return 0; +// } +// +// // TODO : fix +// return 0; +// } +// +// public void leave(int p) { +// +// this.seats[p] = 0; +// } +// +// } + // LC 846 // https://leetcode.com/problems/hand-of-straights/ // 5.29 pm - 5.45 pm