From e7fc73bb0b70ec36fc3fc7beec94f5c80010731f Mon Sep 17 00:00:00 2001 From: Cool <747682928@qq.com> Date: Sun, 29 Sep 2024 23:29:50 +0800 Subject: [PATCH] =?UTF-8?q?2024/9/29=20=E6=AF=8F=E6=97=A5=E4=B8=80?= =?UTF-8?q?=E9=A2=98=E4=B8=8E=E5=91=A8=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LeetCode20240929.java | 35 +++++++++++++++ .../java/com/cool/week_match/week417/Q1.java | 44 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/main/java/com/cool/one_question_per_day/LeetCode20240929.java create mode 100644 src/main/java/com/cool/week_match/week417/Q1.java diff --git a/src/main/java/com/cool/one_question_per_day/LeetCode20240929.java b/src/main/java/com/cool/one_question_per_day/LeetCode20240929.java new file mode 100644 index 0000000..adfb059 --- /dev/null +++ b/src/main/java/com/cool/one_question_per_day/LeetCode20240929.java @@ -0,0 +1,35 @@ +package com.cool.one_question_per_day; + +import org.junit.Test; + +/** + * Created with IntelliJ IDEA. + * + * @Author: Cool + * @Date: 2024/09/29/10:31 + * DayNumber 1 + * Hard 1 + * Level 3 + * Score 1325 + * @Link https://leetcode.cn/problems/time-needed-to-buy-tickets/description/?envType=daily-question&envId=2024-09-29 + * @Description 2073. 买票需要的时间 + */ +public class LeetCode20240929 { + + public int timeRequiredToBuy(int[] tickets, int k) { + int ticket=tickets[k]; + int res=0; + for(int i=0;i queue = new LinkedList<>(); + queue.offerLast('a'); + while (queue.size() < k) { + char c = queue.pollFirst(); + char next; + if (c == 'z') { + next = 'a'; + } else { + next = (char) (c + 1); + } + queue.offerLast(c); + queue.offerLast(next); + } + while (queue.size() > k) { + queue.pollLast(); + } + return queue.peekLast(); + } + @Test + public void test(){ + kthCharacter(5); + } +}