661 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given an integer array of size n , find all elements that appear more than ⌊ n/3 ⌋ times. # Example 1 Input: nums = [3,2,3] Output: [3] # Example 2 Input: nums = [1] Output: [1] # Example 3 Input: nums = [1,2] Output: [1,2] # 解題思路 # Solution import java.util.ArrayList;import...
1.9k 2 分鐘

🌕🌑🌑🌑🌑 # 題目連結 題目連結 Online Judge uDebug # 題目說明 Time limit: 3.000 seconds # 題目 In many computer problems, it is necessary to permute data arrays. That is, the data in an array must be re-arranged in some specified order. One way to permute arbitrary data arrays is to specify the permutations...
1.7k 2 分鐘

⭐️ # 題目敘述 Design a HashMap without using any built-in hash table libraries. Implement the MyHashMap class: MyHashMap() initializes the object with an empty map. void put(int key, int value) inserts a (key, value) pair into the HashMap. If the key already exists in the map, update the corresponding...
2.4k 2 分鐘

🌕🌑🌑🌑🌑 # 題目連結 題目連結 Online Judge uDebug # 題目說明 Time limit: 3.000 seconds # 題目 Given a list of rectangles and a list of points in the x-y plane, determine for each point which figures (if any) contain the point. # Input There will be n(≤ 10) rectangles descriptions, one per line. The first...
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...