[English ver]

# 8. String to Integer (atoi)

Implement atoi to convert a string to an integer.

Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.

Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You are responsible to gather all the input requirements up front.

Update (2015-02-10):
The signature of the C++ function had been updated. If you still see your function signature accepts a const char * argument, please click the reload button to reset your code definition.

[Chinese ver]

[TOC]

# LRU 缓存的魔力

## 解决方案

$$T = m * T_m + T_h + E$$

T = 平均内存引用时间

[TOC]

# LeetCode 7. Reverse Integer

[English ver]Easy

# 7. Reverse Integer

Reverse digits of an integer.

Example1: x = 123, return 321
Example2: x = -123, return -321

Note:
The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows.

[Chinese ver]

[English ver]

# 6. ZigZag Conversion

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)

And then read line by line: “PAHNAPLSIIGYIR”
Write the code that will take a string and make this conversion given a number of rows:

convert(“PAYPALISHIRING”, 3) should return “PAHNAPLSIIGYIR”.

[Chinese ver]

# 6. ZigZag Conversion

convert(“PAYPALISHIRING”, 3) 应该返回 “PAHNAPLSIIGYIR”.

# 5. Longest Palindromic Substring

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Example:

Note: “aba” is also a valid answer.

Example:

I have misunderstood the meaning of the word palindrome , i thought it was the meaning of repeat,finally i know that it was the meaning of a string which is the same when you look from left to right and from right to left.
According to that , we know it has two situation,one the length is odd , another is even .

# 5. Longest Palindromic Substring

Example:

Note: “aba” is also a valid answer.

Example: