這題給定一個 array,和一個 target value,要我們在其中找出四個數字且其和為 target value 的所有
組合。並要求不可以有重複的解。
EX:
nums = [1, 0, -1, 0, -2, 2] , target = 0.
Ans: [ [-1, 0, 0, 1], [-2, -1, 1, 2], [-2, 0, 0, 2] ]
Ans: [ [-1, 0, 0, 1], [-2, -1, 1, 2], [-2, 0, 0, 2] ]
[Ans: [-1, 0, 1], [-1, -1, 2] ]
Output: "fl" Input: ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings.
Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000
Input: "III" Output: 3
Input: "IV" Output: 4
Input: "IX" Output: 9
Input: "LVIII" Output: 58 Explanation: L = 50, V= 5, III = 3.
Input: "MCMXCIV" Output: 1994 Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
'.' Matches any single character. '*' Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
Note:
s could be empty and contains only lowercase letters a-z.p could be empty and contains only lowercase letters a-z, and characters like . or *. inorder = [9,3,15,20,7]3 / \ Ans: 9 20 / \ 15 7
postorder = [9,15,7,20,3]Ans: 3
/ \ 9 20 / \ 15 7
Output: trueInput: -121 Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
這題要我們實作一個將 string 換成 integer 的函數,類似 atoi 的功能。
EX:
Input: " -42"
Output: -42 Explanation: The first non-whitespace character is '-', which is the minus sign. Then take as many numerical digits as possible, which gets 42.
Input: 123 Output: 321
Output: "bab" Note: "aba" is also a valid answer.