962 1 分鐘

⭐️ # 題目敘述 You are given an array nums consisting of positive integers. Return the total frequencies of elements in nums such that those elements all have the maximum frequency. The frequency of an element is the number of occurrences of that element in the array. # Example 1 Input: nums =...
1k 1 分鐘

⭐️ # 題目敘述 Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. # Example 1 Input: head = [1,2,3,4,5] Output: [3,4,5] Explanation: The middle node of the list is node 3. # Example 2 Input: head =...
1.8k 2 分鐘

⭐️⭐️⭐️ # 題目敘述 You start with an initial power of power , an initial score of 0 , and a bag of tokens given as an integer array tokens , where each tokens[i] donates the value of tokeni. Your goal is to maximize the total score by strategically playing these tokens. In one move, you can play an...
1.4k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city fromi to city toi with cost pricei . You are also given three integers src , dst , and k , return the cheapest price...
1.5k 1 分鐘

⭐️ # 題目敘述 In a town, there are n people labeled from 1 to n . There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody. Everybody (except for the town judge) trusts the town judge. There is exactly one person that satisfies...
453 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given two integers left and right that represent the range [left, right] , return the bitwise AND of all numbers in this range, inclusive. # Example 1 Input: left = 5, right = 7 Output: 4 # Example 2 Input: left = 0, right = 0 Output: 0 # Example 3 Input: left = 1, right =...
836 1 分鐘

⭐️ # 題目敘述 Given an array nums containing n distinct numbers in the range [0, n] , return the only number in the range that is missing from the array. # Example 1 Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing...
395 1 分鐘

⭐️ # 題目敘述 Given an integer n , return true if it is a power of two. Otherwise, return false . An integer n is a power of two, if there exists an integer x such that n == 2^x . # Example 1 Input: n = 1 Output: true Explanation: 20 = 1 # Example 2 Input: n = 16 Output: true Explanation: 24 = 16 #...
1.2k 1 分鐘

⭐️⭐️ # 題目敘述 You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers. You should rearrange the elements of nums such that the modified array follows the given conditions: Every consecutive pair of integers have opposite signs. For...
1.2k 1 分鐘

⭐️ # 題目敘述 Given an array of strings words , return the first palindromic string in the array. If there is no such string, return an empty string "" . A string is palindromic if it reads the same forward and backward. # Example 1 Input: words =...