⭐️ # 題目敘述 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 =...
⭐️ # 題目敘述 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:...
⭐️⭐️⭐️ # 題目敘述 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...
⭐️⭐️⭐️ # 題目敘述 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...
⭐️⭐️ # 題目敘述 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...
⭐️⭐️ # 題目敘述 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...
⭐️ # 題目敘述 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,...
🌕🌗🌑🌑🌑 # 題目連結 題目連結 Online Judge uDebug # 題目說明 Time limit: 3.000 seconds # 題目 Given a line of text you will have to find out the frequencies of the ASCII characters present in it. The given lines will contain none of the first 32 or last 128 ASCII characters. Of course lines may end with \n and...
🌕🌗🌑🌑🌑 # 題目連結 題目連結 Online Judge uDebug # 題目說明 Time limit: 3.000 seconds # 題目 This is year 2200AD. Science has progressed a lot in two hundred years. Two hundred years is mentioned here because this problem is being sent back to 2000AD with the help of time machine. Now it is possible to...