# hihocoder-num1015

KMP算法

### 收获与体会

1. 以前就听说过KMP解法，但是今天才真正的去写这个代码，确实很牛；
2. 没有真正掌握，还需加强；
3. 错误解法(2)中的函数不知为何执行出错。

# LeetCode-num020

Valid Parentheses

### Problem

Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid.

The brackets must close in the correct order, “()” and “()[]{}” are all valid but “(]” and “([)]” are not.

### Comment

1. 思路：利用栈，与栈顶元素匹配出栈，否则压栈，循环结束如果栈为空则返回true，否则返回false。

# LeetCode num038

Count and Say

### Problem

The count-and-say sequence is the sequence of integers beginning as follows:
1, 11, 21, 1211, 111221, …

1 is read off as “one 1” or 11.
11 is read off as “two 1s” or 21.
21 is read off as “one 2, then one 1” or 1211.
Given an integer n, generate the nth sequence.

Note: The sequence of integers will be represented as a string.

1. 题目较简单
2. 对字符串操作不够熟练

# LeetCode num165

Compare Version Numbers

### Problem

Compare two version numbers version1 and version2.
If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0.

You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number sequences.
For instance, 2.5 is not “two and a half” or “half way to version three”, it is the fifth second-level revision of the second first-level revision.

Here is an example of version numbers ordering:

Credits:
Special thanks to @ts for adding this problem and creating all test cases.

###Comment

1. 开始理解题意有误
2，用0补全

# LeetCode num067

### Problem

Given two binary strings, return their sum (also a binary string).

For example,
a = “11”
b = “1”
Return “100”.

1. 题比较简单。

# LeetCode num058

### Problem

Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ‘ ‘, return the length of last word in the string.

If the last word does not exist, return 0.

Note: A word is defined as a character sequence consists of non-space characters only.

For example,
Given s = “Hello World”,
return 5.

1. 题比较简单。