[LeetCode]Reverse String
摘要:题目:Reverse String Write a function that takes a string as input and returns the string reversed. Example:Given s = "hello", return "olleh". 题意:逆置字符串 思
阅读全文
[LeetCode]Palindrome Pairs
摘要:题目:Palindrome Pairs Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two wo
阅读全文
[LeetCode]Implement Trie (Prefix Tree)
摘要:题目:Implement Trie (Prefix Tree) 实现字典树。 什么是字典树? Trie树,又叫字典树、前缀树(Prefix Tree)、单词查找树 或 键树,是一种多叉树结构。如下图: 上图是一棵Trie树,表示了关键字集合{“a”, “to”, “tea”, “ted”, “ten
阅读全文
[LeetCode]Integer to English Words
摘要:题目:Integer to English Words Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. For
阅读全文
[LeetCode]Basic Calculator
摘要:题目:Basic Calculator 给定一个合法的运算表达式,该表达式中只包含数字、'+'、'-'、' '、'('、')'。 思路: 简单思考不用看成加减两种运算,直接看成加法,只不过由正负; 如何处理括号呢?因为只看成加法,括号会影响的是数值的正负,那么通过去括号运算法则来修改当前值的正负就可
阅读全文
[LeetCode]Shortest Palindrome
摘要:题目:Shortest Palindrome 给定字符串,在前面增加最少字符使其组成回文字符串。 思想: 只要找到从字符串头部开始的最长回文子串,就能将剩下的字符串逆置后拼接到前面而得到最短的回文字符串。 /**判断字符串是回文的**/ bool isPalindrome(string s){ if
阅读全文
[LeetCode]Isomorphic Strings
摘要:题目:Isomorphic Strings 给定两个字符串(长度相等),判断它们是否同构;同构:两个字符串的字母对应位置是否能够一一对应。 For example,Given "egg", "add", return true. Given "foo", "bar", return false. G
阅读全文