Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. The string can contain additional characters after those that form the integral number, which are ignored
The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) 1 2 3 P A H N A P L S I I G Y I R And then read line by line: “PAHNAPLSIIGYIR” Write the code that will take a string and make this conversion given a number
Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given 1 2 inorder = [9,3,15,20,7] postorder = [9,15,7,20,3] Return the following binary tree: 1 2 3 4 5 3 / \ 9 20 / \ 15 7 解: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: 1 2 3 Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: 1 2 Input: "cbbd" Output: "bb" 用的 Manacher 算法,如果对注释不太明白可以搜网上的图解。