File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
main/java/com/fishercoder/solutions
test/java/com/fishercoder Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ Your ideas/fixes/algorithms are more than welcome!
29
29
30
30
| # | Title | Solutions | Time | Space | Video | Difficulty | Tag
31
31
|-----|----------------|---------------|---------------|---------------|--------|-------------|-------------
32
+ | 933| [ Number of Recent Calls] ( https://leetcode.com/problems/number-of-recent-calls/ ) | [ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_933.java ) | O(n) | O(n) | | Easy|
32
33
| 929| [ Unique Email Addresses] ( https://leetcode.com/problems/unique-email-addresses/ ) | [ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_929.java ) | O(n) | O(n) | | Easy|
33
34
| 922| [ Sort Array By Parity II] ( https://leetcode.com/problems/sort-array-by-parity-ii/ ) | [ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_922.java ) | O(n) | O(1) | | Easy|
34
35
| 917| [ Reverse Only Letters] ( https://leetcode.com/problems/reverse-only-letters/ ) | [ Solution] ( ../master/src/main/java/com/fishercoder/solutions/_917.java ) | O(n) | O(n) | | Easy|
Original file line number Diff line number Diff line change
1
+ package com .fishercoder .solutions ;
2
+
3
+ import java .util .Deque ;
4
+ import java .util .LinkedList ;
5
+
6
+ public class _933 {
7
+ public static class Solution1 {
8
+ public static class RecentCounter {
9
+
10
+ Deque <Integer > deque ;
11
+
12
+ public RecentCounter () {
13
+ deque = new LinkedList <>();
14
+ }
15
+
16
+ public int ping (int t ) {
17
+ while (!deque .isEmpty () && t - deque .getFirst () > 3000 ) {
18
+ deque .removeFirst ();
19
+ }
20
+ deque .addLast (t );
21
+ return deque .size ();
22
+ }
23
+ }
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ package com .fishercoder ;
2
+
3
+ import com .fishercoder .solutions ._933 ;
4
+ import org .junit .BeforeClass ;
5
+ import org .junit .Test ;
6
+
7
+ import static org .junit .Assert .assertEquals ;
8
+
9
+ public class _933Test {
10
+ private static _933 .Solution1 .RecentCounter solution1 ;
11
+
12
+ @ BeforeClass
13
+ public static void setup () {
14
+ solution1 = new _933 .Solution1 .RecentCounter ();
15
+ }
16
+
17
+ @ Test
18
+ public void test1 () {
19
+ assertEquals (1 , solution1 .ping (1 ));
20
+ }
21
+
22
+ }
You can’t perform that action at this time.
0 commit comments