File tree 3 files changed +34
-6
lines changed
3 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 251
251
| 922 | [ Sort Array by Parity II] ( https://leetcode.com/problems/sort-array-by-parity-ii ) | [ ![ Java] ( assets/java.png )] ( src/SortArrayByParityII.java ) |
252
252
| 925 | [ Long Pressed Name] ( https://leetcode.com/problems/long-pressed-name ) | [ ![ Java] ( assets/java.png )] ( src/LongPressedName.java ) |
253
253
| 929 | [ Unique Email Addresses] ( https://leetcode.com/problems/unique-email-addresses ) | [ ![ Java] ( assets/java.png )] ( src/UniqueEmailAddresses.java ) |
254
- | 933 | [ Number of Recent Calls] ( https://leetcode.com/problems/number-of-recent-calls ) | |
254
+ | 933 | [ Number of Recent Calls] ( https://leetcode.com/problems/number-of-recent-calls ) | [ ![ Java ] ( assets/java.png )] ( src/NumberOfRecentCalls.java ) |
255
255
| 937 | [ Reorder Data In Log Files] ( https://leetcode.com/problems/reorder-data-in-log-files ) | |
256
256
| 938 | [ Range Sum of BST] ( https://leetcode.com/problems/range-sum-of-bst ) | |
257
257
| 941 | [ Valid Mountain Array] ( https://leetcode.com/problems/valid-mountain-array ) | |
Original file line number Diff line number Diff line change
1
+ public class NumberOfRecentCalls {
2
+ class RecentCounter {
3
+ private Node head ;
4
+ private Node tail ;
5
+ private int size = 0 ;
6
+
7
+ public int ping (int t ) {
8
+ size ++;
9
+ if (head == null ) {
10
+ head = new Node (t );
11
+ tail = head ;
12
+ } else {
13
+ tail .next = new Node (t );
14
+ tail = tail .next ;
15
+ }
16
+ while (head .val < t - 3000 ) {
17
+ head = head .next ;
18
+ size --;
19
+ }
20
+ return size ;
21
+ }
22
+
23
+ private class Node {
24
+ int val ;
25
+ Node next ;
26
+
27
+ Node (final int val ) {
28
+ this .val = val ;
29
+ }
30
+ }
31
+ }
32
+ }
Original file line number Diff line number Diff line change 1
1
public class TeemoAttacking {
2
- public static void main (String [] args ) {
3
- System .out .println (findPoisonedDuration (new int [] {1 , 2 }, 2 ));
4
- }
5
-
6
- public static int findPoisonedDuration (int [] timeSeries , int duration ) {
2
+ public int findPoisonedDuration (int [] timeSeries , int duration ) {
7
3
int poisonDuration = 0 ;
8
4
for (int i = 0 , current = timeSeries [0 ] - 1 ; i < timeSeries .length ; i ++) {
9
5
poisonDuration += duration - Math .max (0 , Math .max (current , timeSeries [i ] - 1 ) - timeSeries [i ] + 1 );
You can’t perform that action at this time.
0 commit comments