Skip to content

Commit 0817886

Browse files
committed
Daily
1 parent 56fc063 commit 0817886

File tree

10 files changed

+113
-5
lines changed

10 files changed

+113
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (412 solved)
1+
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (413 solved)
22

33
> My LeetCode Profile: [Zanger](https://leetcode.com/u/Zanger/)
44
@@ -332,6 +332,7 @@ This repo is a collection of my LeetCode solutions, primarily written in Python,
332332
| 1696 | [Jump Game VI](<https://leetcode.com/problems/jump-game-vi>) | Medium | | [solution](<markdowns/_1696. Jump Game VI.md>) | java, py |
333333
| 1698 | [Number of Distinct Substrings in a String](<https://leetcode.com/problems/number-of-distinct-substrings-in-a-string>) | Medium | | [solution](<markdowns/_1698. Number of Distinct Substrings in a String.md>) | java, py |
334334
| 1700 | [Number of Students Unable to Eat Lunch](<https://leetcode.com/problems/number-of-students-unable-to-eat-lunch>) | Easy | | [solution](<markdowns/_1700. Number of Students Unable to Eat Lunch.md>) | py |
335+
| 1701 | [Average Waiting Time](<https://leetcode.com/problems/average-waiting-time>) | Medium | Daily | [solution](<markdowns/_1701. Average Waiting Time.md>) | js, py |
335336
| 1721 | [Swapping Nodes in a Linked List](<https://leetcode.com/problems/swapping-nodes-in-a-linked-list>) | Medium | | [solution](<markdowns/_1721. Swapping Nodes in a Linked List.md>) | c |
336337
| 1730 | [Shortest Path to Get Food](<https://leetcode.com/problems/shortest-path-to-get-food>) | Medium | | [solution](<markdowns/_1730. Shortest Path to Get Food.md>) | py |
337338
| 1736 | [Latest Time by Replacing Hidden Digits](<https://leetcode.com/problems/latest-time-by-replacing-hidden-digits>) | Easy | | [solution](<markdowns/_1736. Latest Time by Replacing Hidden Digits.md>) | c |

markdowns/Daily_Questions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Dates are for the date I completed the question so due to the my time zone and h
66

77
| # | Title | Level | Cats | Solution | Languages | Date Complete |
88
|-----:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:------------|:---------------------------------------------------------------------------------------------------|:-----------------------------|:----------------|
9+
| 1701 | [Average Waiting Time](<https://leetcode.com/problems/average-waiting-time>) | Medium | Daily | [solution](<_1701. Average Waiting Time.md>) | js, py | Jul 08, 2024 |
910
| 1823 | [Find the Winner of the Circular Game](<https://leetcode.com/problems/find-the-winner-of-the-circular-game>) | Medium | Daily | [solution](<_1823. Find the Winner of the Circular Game.md>) | c, cpp, java, js, py | Jul 07, 2024 |
1011
| 1518 | [Water Bottles](<https://leetcode.com/problems/water-bottles>) | Easy | Daily | [solution](<_1518. Water Bottles.md>) | c, cpp, cs, java, js, py, ts | Jul 06, 2024 |
1112
| 2582 | [Pass the Pillow](<https://leetcode.com/problems/pass-the-pillow>) | Easy | Daily | [solution](<_2582. Pass the Pillow.md>) | c, cpp, cs, java, js, py | Jul 05, 2024 |

markdowns/Questions_By_Code_Length.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ Calculations are based on the code files's byte sizes.
211211
| 426 | [Convert Binary Search Tree to Sorted Doubly Linked List](<https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list>) | Medium | | [solution](<_426. Convert Binary Search Tree to Sorted Doubly Linked List.md>) | py | Jun 11, 2024 |
212212
| 113 | [Path Sum II](<https://leetcode.com/problems/path-sum-ii>) | Medium | | [solution](<_113. Path Sum II.md>) | py | Jul 03, 2024 |
213213
| 129 | [Sum Root to Leaf Numbers](<https://leetcode.com/problems/sum-root-to-leaf-numbers>) | Medium | | [solution](<_129. Sum Root to Leaf Numbers.md>) | py | Jun 07, 2024 |
214+
| 1701 | [Average Waiting Time](<https://leetcode.com/problems/average-waiting-time>) | Medium | Daily | [solution](<_1701. Average Waiting Time.md>) | js, py | Jul 08, 2024 |
214215
| 25 | [Reverse Nodes in k-Group](<https://leetcode.com/problems/reverse-nodes-in-k-group>) | Hard | N150 | [solution](<_25. Reverse Nodes in k-Group.md>) | c | Jun 06, 2024 |
215216
| 695 | [Max Area of Island](<https://leetcode.com/problems/max-area-of-island>) | Medium | N150 | [solution](<_695. Max Area of Island.md>) | c | Jun 23, 2024 |
216217
| 565 | [Array Nesting](<https://leetcode.com/problems/array-nesting>) | Medium | | [solution](<_565. Array Nesting.md>) | py | Jul 02, 2024 |

markdowns/Questions_By_Recent.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Calculations are based on the date of the first solve.
66

77
| # | Title | Level | Cats | Solution | Languages | Date Complete |
88
|-----:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:---------------|:---------------------------------------------------------------------------------------------------|:---------------------------------|:----------------|
9+
| 1701 | [Average Waiting Time](<https://leetcode.com/problems/average-waiting-time>) | Medium | Daily | [solution](<_1701. Average Waiting Time.md>) | js, py | Jul 08, 2024 |
910
| 2634 | [Filter Elements from Array](<https://leetcode.com/problems/filter-elements-from-array>) | Easy | | [solution](<_2634. Filter Elements from Array.md>) | js | Jul 08, 2024 |
1011
| 2635 | [Apply Transform Over Each Element in Array](<https://leetcode.com/problems/apply-transform-over-each-element-in-array>) | Easy | | [solution](<_2635. Apply Transform Over Each Element in Array.md>) | js | Jul 08, 2024 |
1112
| 2665 | [Counter II](<https://leetcode.com/problems/counter-ii>) | Easy | | [solution](<_2665. Counter II.md>) | js | Jul 08, 2024 |

markdowns/Topics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
------
66

7-
- [Array](<by_topic/Array.md>) (191 completed)
7+
- [Array](<by_topic/Array.md>) (192 completed)
88
- [Hash Table](<by_topic/Hash Table.md>) (92 completed)
99
- [String](<by_topic/String.md>) (88 completed)
1010
- [Depth-First Search](<by_topic/Depth-First Search.md>) (68 completed)
@@ -18,7 +18,7 @@
1818
- [Stack](<by_topic/Stack.md>) (37 completed)
1919
- [Greedy](<by_topic/Greedy.md>) (32 completed)
2020
- [Matrix](<by_topic/Matrix.md>) (31 completed)
21-
- [Simulation](<by_topic/Simulation.md>) (28 completed)
21+
- [Simulation](<by_topic/Simulation.md>) (29 completed)
2222
- [Bit Manipulation](<by_topic/Bit Manipulation.md>) (25 completed)
2323
- [Design](<by_topic/Design.md>) (25 completed)
2424
- [Dynamic Programming](<by_topic/Dynamic Programming.md>) (23 completed)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# 1701. [Average Waiting Time](<https://leetcode.com/problems/average-waiting-time>)
2+
3+
*All prompts are owned by LeetCode. To view the prompt, click the title link above.*
4+
5+
*[Back to top](<../README.md>)*
6+
7+
------
8+
9+
> *First completed : July 08, 2024*
10+
>
11+
> *Last updated : July 08, 2024*
12+
13+
14+
------
15+
16+
> **Related Topics** : **[Array](<by_topic/Array.md>), [Simulation](<by_topic/Simulation.md>)**
17+
>
18+
> **Acceptance Rate** : **63.674 %**
19+
20+
21+
------
22+
23+
## Solutions
24+
25+
- [m1701 Daily.py](<../my-submissions/m1701 Daily.py>)
26+
- [m1701.js](<../my-submissions/m1701.js>)
27+
### Python
28+
#### [m1701 Daily.py](<../my-submissions/m1701 Daily.py>)
29+
```Python
30+
class Solution:
31+
def averageWaitingTime(self, customers: List[List[int]]) -> float:
32+
output = 0
33+
currentTime = customers[0][0]
34+
custCount = len(customers)
35+
36+
for i, customer in enumerate(customers) :
37+
if customer[0] > currentTime :
38+
currentTime = customer[0]
39+
output += (currentTime + customer[1]) - customer[0]
40+
currentTime += customer[1]
41+
42+
return output / custCount
43+
```
44+
45+
### JavaScript
46+
#### [m1701.js](<../my-submissions/m1701.js>)
47+
```JavaScript
48+
/**
49+
* @param {number[][]} customers
50+
* @return {number}
51+
*/
52+
var averageWaitingTime = function(customers) {
53+
var output = 0;
54+
var currentTime = 0;
55+
56+
function cust(customer) {
57+
if (customer[0] > currentTime) {
58+
currentTime = customer[0];
59+
}
60+
61+
output += (currentTime + customer[1]) - customer[0];
62+
currentTime += customer[1];
63+
}
64+
65+
customers.forEach(cust);
66+
return output / customers.length;
67+
};
68+
```
69+

markdowns/by_topic/Array.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [Array](<https://leetcode.com/tag/Array/>) (191 completed)
1+
# [Array](<https://leetcode.com/tag/Array/>) (192 completed)
22

33
*[Back to top](<../../README.md>)*
44

@@ -138,6 +138,7 @@
138138
| 1684 | [Count the Number of Consistent Strings](<https://leetcode.com/problems/count-the-number-of-consistent-strings>) | Easy | | [solution](<../_1684. Count the Number of Consistent Strings.md>) | c, py | Jun 06, 2024 |
139139
| 1696 | [Jump Game VI](<https://leetcode.com/problems/jump-game-vi>) | Medium | | [solution](<../_1696. Jump Game VI.md>) | java, py | Jul 02, 2024 |
140140
| 1700 | [Number of Students Unable to Eat Lunch](<https://leetcode.com/problems/number-of-students-unable-to-eat-lunch>) | Easy | | [solution](<../_1700. Number of Students Unable to Eat Lunch.md>) | py | Jun 01, 2024 |
141+
| 1701 | [Average Waiting Time](<https://leetcode.com/problems/average-waiting-time>) | Medium | Daily | [solution](<../_1701. Average Waiting Time.md>) | js, py | Jul 08, 2024 |
141142
| 1730 | [Shortest Path to Get Food](<https://leetcode.com/problems/shortest-path-to-get-food>) | Medium | | [solution](<../_1730. Shortest Path to Get Food.md>) | py | Jun 26, 2024 |
142143
| 1743 | [Restore the Array From Adjacent Pairs](<https://leetcode.com/problems/restore-the-array-from-adjacent-pairs>) | Medium | | [solution](<../_1743. Restore the Array From Adjacent Pairs.md>) | py | Jun 26, 2024 |
143144
| 1748 | [Sum of Unique Elements](<https://leetcode.com/problems/sum-of-unique-elements>) | Easy | | [solution](<../_1748. Sum of Unique Elements.md>) | c | Jun 06, 2024 |

markdowns/by_topic/Simulation.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [Simulation](<https://leetcode.com/tag/Simulation/>) (28 completed)
1+
# [Simulation](<https://leetcode.com/tag/Simulation/>) (29 completed)
22

33
*[Back to top](<../../README.md>)*
44

@@ -17,6 +17,7 @@
1717
| 1518 | [Water Bottles](<https://leetcode.com/problems/water-bottles>) | Easy | Daily | [solution](<../_1518. Water Bottles.md>) | c, cpp, cs, java, js, py, ts | Jul 06, 2024 |
1818
| 1535 | [Find the Winner of an Array Game](<https://leetcode.com/problems/find-the-winner-of-an-array-game>) | Medium | | [solution](<../_1535. Find the Winner of an Array Game.md>) | py | Jun 08, 2024 |
1919
| 1700 | [Number of Students Unable to Eat Lunch](<https://leetcode.com/problems/number-of-students-unable-to-eat-lunch>) | Easy | | [solution](<../_1700. Number of Students Unable to Eat Lunch.md>) | py | Jun 01, 2024 |
20+
| 1701 | [Average Waiting Time](<https://leetcode.com/problems/average-waiting-time>) | Medium | Daily | [solution](<../_1701. Average Waiting Time.md>) | js, py | Jul 08, 2024 |
2021
| 1823 | [Find the Winner of the Circular Game](<https://leetcode.com/problems/find-the-winner-of-the-circular-game>) | Medium | Daily | [solution](<../_1823. Find the Winner of the Circular Game.md>) | c, cpp, java, js, py | Jul 07, 2024 |
2122
| 1929 | [Concatenation of Array](<https://leetcode.com/problems/concatenation-of-array>) | Easy | | [solution](<../_1929. Concatenation of Array.md>) | c, java, py | Jun 03, 2024 |
2223
| 2011 | [Final Value of Variable After Performing Operations](<https://leetcode.com/problems/final-value-of-variable-after-performing-operations>) | Easy | | [solution](<../_2011. Final Value of Variable After Performing Operations.md>) | c | Jun 03, 2024 |

my-submissions/m1701 Daily.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def averageWaitingTime(self, customers: List[List[int]]) -> float:
3+
output = 0
4+
currentTime = customers[0][0]
5+
custCount = len(customers)
6+
7+
for i, customer in enumerate(customers) :
8+
if customer[0] > currentTime :
9+
currentTime = customer[0]
10+
output += (currentTime + customer[1]) - customer[0]
11+
currentTime += customer[1]
12+
13+
return output / custCount

my-submissions/m1701.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @param {number[][]} customers
3+
* @return {number}
4+
*/
5+
var averageWaitingTime = function(customers) {
6+
var output = 0;
7+
var currentTime = 0;
8+
9+
function cust(customer) {
10+
if (customer[0] > currentTime) {
11+
currentTime = customer[0];
12+
}
13+
14+
output += (currentTime + customer[1]) - customer[0];
15+
currentTime += customer[1];
16+
}
17+
18+
customers.forEach(cust);
19+
return output / customers.length;
20+
};

0 commit comments

Comments
 (0)