969 1 分鐘

⭐️ # 題目敘述 Given a string array words , return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order. # Example 1 Input: words = ["bella","label","roller"] Output:...
939 1 分鐘

⭐️ # 題目敘述 Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. Letters are case sensitive, for example, "Aa" is not considered a palindrome. Palindrome A palindrome is a string that...
1.2k 1 分鐘

⭐️⭐️ # 題目敘述 You are given two strings s and t consisting of only lowercase English letters. Return the minimum number of characters that need to be appended to the end of s so that t becomes a subsequence of s . A subsequence is a string that can be derived from another string by deleting some or no...
696 1 分鐘

⭐️ # 題目敘述 Write a function that reverses a string. The input string is given as an array of characters s . You must do this by modifying the input array in-place with O(1) extra memory. # Example 1 Input: s =...
702 1 分鐘

⭐️ # 題目敘述 You are given a string s . The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters. Return the score of s . # Example 1 Input: s = "hello" Output: 13 Explanation: The ASCII values of the characters in s are:...
1.1k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given an integer array nums , in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in any order. You must write an algorithm that runs in linear runtime complexity and uses...
1k 1 分鐘

⭐️⭐️⭐️ # 題目敘述 Given an array of integers arr . We want to select three indices i , j and k where (0 <= i < j <= k < arr.length) . Let's define a and b as follows: a = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1] b = arr[j] ^ arr[j + 1] ^ ... ^ arr[k] Note that ^ denotes...
1k 1 分鐘

⭐️⭐️ # 題目敘述 Given the binary representation of an integer as a string s , return the number of steps to reduce it to 1 under the following rules: If the current number is even, you have to divide it by 2 . If the current number is odd, you have to add 1 to it. It is guaranteed that you can always...
1.3k 1 分鐘

⭐️⭐️ # 題目敘述 You are given two strings s and t of the same length and an integer maxCost . You want to change s to t . Changing the ith character of s to ith character of t costs |s[i] - t[i]| (i.e., the absolute difference between the ASCII values of the characters). Return the maximum length of a...
1k 1 分鐘

⭐️ # 題目敘述 You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x . Notice that x does not have to be an element in nums . Return x if the array is special,...