1.6k 1 分鐘

⭐️ # 題目敘述 You are given an integer array score of size n , where score[i] is the score of the ith athlete in a competition. All the scores are guaranteed to be unique. The athletes are placed based on their scores, where the 1st place athlete has the highest score, the 2nd place athlete has the 2nd...
1.2k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 You are given the head of a non-empty linked list representing a non-negative integer without leading zeroes. Return the head of the linked list after doubling it. # Example 1 Input: head = [1,8,9] Output: [3,7,8] Explanation: The figure above corresponds to the given linked list...
1.2k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 You are given the head of a linked list. Remove every node which has a node with a greater value anywhere to the right side of it. Return the head of the modified linked list. # Example 1 Input: head = [5,2,13,3,8] Output: [13,8] Explanation: The nodes that should be removed are 5, 2...
1.8k 2 分鐘

⭐️⭐️ # 題目敘述 Given two version numbers, version1 and version2 , compare them. Version numbers consist of one or more revisions joined by a dot '.' . Each revision consists of digits and may contain leading zeros. Every revision contains at least one character. Revisions are 0-indexed from...
791 1 分鐘

⭐️ # 題目敘述 Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array. Return the positive integer k . If there is no such integer, return -1 . # Example 1 Input: nums = [-1,2,-3,3] Output: 3 Explanation: 3 is the only valid...
1.3k 1 分鐘

⭐️ # 題目敘述 Given a 0-indexed string word and a character ch , reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word , do nothing. For example, if word = "abcdefd" and ch =...
1.3k 1 分鐘

⭐️⭐️ # 題目敘述 You are given a 0-indexed integer array nums and a positive integer k . You can apply the following operation on the array any number of times: Choose any element of the array and flip a bit in its binary representation. Flipping a bit means changing a 0 to 1 or vice versa. Return the...
1.3k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 You are given a string s consisting of lowercase letters and an integer k . We call a string t ideal if the following conditions are satisfied: t is a subsequence of the string s . The absolute difference in the alphabet order of every two adjacent letters in t is less than or equal...
526 1 分鐘

⭐️ # 題目敘述 The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. Given n , return the value of Tn. # Example 1 Input: n = 4 Output: 4 Explanation: T3 = 0 + 1 + 1 = 2 T4 = 1 + 1 + 2 = 4 # Example 2 Input: n = 25 Output: 1389537 #...
2.6k 2 分鐘

⭐️⭐️⭐️ # 題目敘述 You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' . The wheels can rotate freely and wrap around: for example we can turn...