899 1 分鐘

⭐️ # 題目敘述 You have a set of integers s , which originally contains all the numbers from 1 to n . Unfortunately, due to some error, one of the numbers in s got duplicated to another number in the set, which results in repetition of one number and loss of another number. You are given an integer array...
1.4k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two...
1.2k 1 分鐘

# 臺灣麻將規則 由於我們是要寫麻將對局,不是要當賭神😝,所以我這裡只列出幾個需要關注的內容,一些過於細節的就不多加描述。 # 排組介紹 一副麻將總共 144 張牌 136 張基本牌,每種各四張 1 ~ 9 萬 1 ~ 9 條 1 ~ 9 筒 中、發、白 東、南、西、北 4 張花牌 梅、蘭、竹、菊 4 張四季牌 春、夏、秋、冬 # 動作 抓位: 每圈開始前,大家把東、南、西、北風牌放到桌上,並且蓋上,四家任意各拿一張牌後,依照所拿到的風牌決定座位,就叫做「麻將抓位」。 補花:...
889 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given an array of integers arr, find the sum of min(b) , where b ranges over every (contiguous) subarray of arr . Since the answer may be large, return the answer modulo 10^9 + 7 . # Example 1 Input: arr = [3,1,2,4] Output: 17 Explanation: Subarrays are [3], [1], [2], [4], [3,1],...
1.6k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given an n x n array of integers matrix , return the minimum sum of any falling path through matrix . A falling path starts at any element in the first row and chooses the element in the next row that is either directly below or diagonally left/right. Specifically, the next element...
1k 1 分鐘

⭐️ # 題目敘述 You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? # Example 1 Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1 step + 1 step 2 steps # Example...
2.3k 2 分鐘

⭐️⭐️⭐️ # 題目敘述 Implement the RandomizedSet class: RandomizedSet() Initializes the RandomizedSet object. bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise. bool remove(int val) Removes an item val from the set if present....
1.9k 2 分鐘

⭐️⭐️⭐️ # 題目敘述 You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match. Return a list answer of size 2 where: answer[0] is a list of all players that have not lost any matches. answer[1] is a list of all players...
1.7k 2 分鐘

⭐️⭐️⭐️ # 題目敘述 Two strings are considered close if you can attain one from the other using the following operations: Operation 1: Swap any two existing characters. For example, abcde -> aecdb Operation 2: Transform every occurrence of one existing character into another existing character,...
1k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 You are given two strings of the same length s and t . In one step you can choose any character of t and replace it with another character. Return the minimum number of steps to make t an anagram of s . An Anagram of a string is a string that contains the same characters with a...