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...
2k 2 分鐘

🌕🌗🌑🌑🌑 # 題目連結 題目連結 Online Judge uDebug # 題目說明 Time limit: 3.000 seconds # 題目 Probability has always been an integrated part of computer algorithms. Where the deterministic algorithms have failed to solve a problem in short time, probabilistic algorithms have come to the rescue. In this problem...
1.2k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given string num representing a non-negative integer num , and an integer k , return the smallest possible integer after removing k digits from num . # Example 1 Input: num = "1432219", k = 3 Output: "1219" Explanation: Remove the three digits 4, 3,...