622 1 分鐘

⭐️ # 題目敘述 Given an array nums of size n , return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. # Example 1 Input: nums = [3,2,3] Output: 3 # Example 2 Input: nums =...
680 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given an integer n , return the least number of perfect square numbers that sum to n . A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 1 , 4 , 9 , and 16 are perfect squares while 3 and 11 are...
1.5k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given a string s , sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string. Return the sorted string. If there are multiple answers, return any of them. # Example 1 Input: s =...
629 1 分鐘

⭐️ # 題目敘述 Given a string s , find the first non-repeating character in it and return its index. If it does not exist, return -1 . # Example 1 Input: s = "leetcode" Output: 0 # Example 2 Input: s = "loveleetcode" Output: 2 # Example 3 Input: s =...
892 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given an integer array arr , partition the array into (contiguous) subarrays of length at most k . After partitioning, each subarray has their values changed to become the maximum value of that subarray. Return the largest sum of the given array after partitioning. Test cases are...
778 1 分鐘

⭐️⭐️⭐️ # 題目敘述 An integer has sequential digits if and only if each digit in the number is one more than the previous digit. Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits. # Example 1 Input: low = 100, high = 300 Output: [123,234] # Example...
1.2k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 You are given an integer array nums of size n and a positive integer k . Divide the array into one or more arrays of size 3 satisfying the following conditions: Each element of nums should be in exactly one array. The difference between any two elements in one array is less than or...
1.3k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0...