695 1 分鐘

⭐️ # 題目敘述 Given an array of integers nums , return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j . # Example 1 Input: nums = [1,2,3,1,1,3] Output: 4 Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed. # Example 2 Input: nums =...
2k 2 分鐘

⭐️⭐️⭐️ # 題目敘述 There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B' . You are given a string colors of length n where colors[i] is the color of the ith piece. Alice and Bob are playing a game where they take alternating turns removing pieces from...
605 1 分鐘

⭐️ # 題目敘述 Given a string s , reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. # Example 1 Input: s = "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc" # Example...
955 1 分鐘

⭐️ # 題目敘述 Given an integer array nums , move all the even integers at the beginning of the array followed by all the odd integers. Return any array that satisfies this condition. # Example 1 Input: nums = [3,1,2,4] Output: [2,4,3,1] Explanation: The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would...
2.1k 2 分鐘

🌕🌑🌑🌑🌑 # 題目連結 題目連結 Online Judge uDebug # 題目說明 Time limit: 3.000 seconds # 題目 Write a complete program that will correctly decode a set of characters into a valid message. Your program should read a given file of a simple coded set of characters and print the exact message that the characters...
1.4k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 You are given an encoded string s . To decode the string to a tape, the encoded string is read one character at a time and the following steps are taken: If the character read is a letter, that letter is written onto the tape. If the character read is a digit d , the entire current...
1.5k 1 分鐘

🌕🌗🌑🌑🌑 # 題目連結 題目連結 Online Judge uDebug # 題目說明 Time limit: 3.000 seconds # 題目 A character string is said to have period k if it can be formed by concatenating one or more repetitions of another string of length k . For example, the string ”abcabcabcabc” has period 3 , since it is formed by 4...
1.5k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given a string s , remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. Lexicographically Smaller A string a is lexicographically smaller than a string b if in the...
526 1 分鐘

⭐️ # 題目敘述 You are given two strings s and t . String t is generated by random shuffling string s and then add one more letter at a random position. Return the letter that was added to t . # Example 1 Input: s = "abcd", t = "abcde" Output:...
3.3k 3 分鐘

🌕🌑🌑🌑🌑 # 題目連結 題目連結 Online Judge uDebug # 題目說明 Time limit: 3.000 seconds # 題目 Judge Ito is having a problem with people subpoenaed for jury duty giving rather lame excuses in order to avoid serving. In order to reduce the amount of time required listening to goofy excuses, Judge Ito has asked...