Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4c0c819

Browse files
add 2073
1 parentefef008 commit4c0c819

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|2073|[Time Needed to Buy Tickets](https://leetcode.com/problems/time-needed-to-buy-tickets/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2073.java)||Easy||
1112
|2070|[Most Beautiful Item for Each Query](https://leetcode.com/problems/most-beautiful-item-for-each-query/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2070.java)||Medium||
1213
|2068|[Check Whether Two Strings are Almost Equivalent](https://leetcode.com/problems/check-whether-two-strings-are-almost-equivalent/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2068.java)||Easy||
1314
|2063|[Vowels of All Substrings](https://leetcode.com/problems/vowels-of-all-substrings/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2063.java)||Medium||
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.Deque;
4+
importjava.util.LinkedList;
5+
6+
publicclass_2073 {
7+
publicstaticclassSolution1 {
8+
publicinttimeRequiredToBuy(int[]tickets,intk) {
9+
inttime =0;
10+
Deque<int[]>queue =newLinkedList<>();
11+
for (inti =0;i <tickets.length;i++) {
12+
queue.addLast(newint[]{tickets[i],i});
13+
}
14+
while (!queue.isEmpty()) {
15+
int[]curr =queue.pollFirst();
16+
if (curr[0] -1 >0) {
17+
queue.addLast(newint[]{curr[0] -1,curr[1]});
18+
}
19+
time++;
20+
if (curr[1] ==k &&curr[0] -1 ==0) {
21+
returntime;
22+
}
23+
}
24+
returntime;
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp