Number of Segments in a String
Number of Segments in a StringCount the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. Please note that the string does not contain an
Number of Segments in a StringCount the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. Please note that the string does not contain an
Add StringsGiven two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < 5100. Both num1 and num2 contains only
Third Maximum NumberGiven a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). Example 1
Longest PalindromeGiven a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This is case sensitive, for example
Convert a Number to HexadecimalGiven an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used. Note: All letters in hexadecimal (a-f) must b
Sum of Left LeavesFind the sum of all left leaves in a given binary tree. For Example:1234567 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 resp
Binary WatchA binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least signifi
Valid Perfect SquareGiven a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function such as sqrt. Example 1:12
Sum of Two IntegersCalculate the sum of two integers a and b, but you are not allowed to use the operator + and -. For Example:1Given a = 1 and b = 2, return 3. 提示 解題應用 BitManipulation XOR,AND
Reverse Vowels of a StringWrite a function that takes a string as input and reverse only the vowels of a string. Example1:1Given s = "hello", return "holle". Example 2:1Given s =
Ransom NoteGiven an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the ma
Intersection of Two ArraysGiven two arrays, write a function to compute their intersection. ###For Example: 1Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element in the result
Intersection of Two Arrays IIGiven two arrays, write a function to compute their intersection. For Example:1Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each element in the resul
First Unique Character in a StringGiven a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1. For Examples:12345s = "leetcode"return
Reverse StringWrite a function that takes a string as input and returns the string reversed. For Example:1Given s = "hello", return "olleh". 提示 解題應用 TwoPointers String D
Power of FourGiven an integer (signed 32 bits), write a function to check whether it is a power of 4. For Example:1Given num = 16, return true. Given num = 5, return false. Follow up: Could you solve
Power of ThreeGiven an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? 提示 解題應用 Math 腦力激盪 Default:123func isP
Range Sum Query - ImmutableGiven an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. For Example:12345Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) ->
Word PatternGiven a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in