不为成仙,只为在这红尘中等你回来。

20. Valid Parentheses [Easy] [String]

    ### 题意 Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。 An input string is valid if: 有效字符串需满足: 1.Open brackets must ...

    阅读全文>>

2018年4月23日 23:25 作者:nancy 分类:[LeetCode] 1331

443. String Compression [Easy] [String]

    ### 题意 Given an array of characters, compress it in-place. 给定一组字符,使用原地算法将其压缩。 The length after compression must always be smaller than or equal to the original array. 压缩后的长度必须始终小于或等于原数组长度。 Every element of the array should be a charac...

    阅读全文>>

2018年4月21日 13:48 作者:nancy 分类:[LeetCode] 1427

459. Repeated Substring Pattern [Easy] [String]

    ### 题意 Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not...

    阅读全文>>

2018年4月20日 23:04 作者:nancy 分类:[LeetCode] 1308

434. Number of Segments in a String [Easy] [String]

    ### 题意 Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. 统计字符串中的单词个数,这里的单词指的是连续的非空字符。 Please note that the string does not contain any non-printable characters. 请注意,...

    阅读全文>>

2018年4月19日 22:43 作者:nancy 分类:[LeetCode] 1281

387. First Unique Character in a String [Easy] [String]

    ### 题意 Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 Examples: ``` s = "leetcode" return 0. s = "loveleetcode", return ...

    阅读全文>>

2018年4月18日 22:22 作者:nancy 分类:[LeetCode] 1259

383. Ransom Note [Easy] [String]

    ### 题意 Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false. 给定一个赎...

    阅读全文>>

2018年4月17日 23:45 作者:nancy 分类:[LeetCode] 1284

345. Reverse Vowels of a String [Easy] [String | Two Pointers]

    ### 题意 Write a function that takes a string as input and reverse only the vowels of a string. 编写一个函数,以字符串作为输入,反转该字符串中的元音字母。 ```python Example 1: Given s = "hello", return "holle". Example 2: Given s = "leetcode", return "leotcede". ```...

    阅读全文>>

2018年4月16日 23:23 作者:nancy 分类:[LeetCode] 1235

344. Reverse String [Easy] [String | Two Pointers]

    ### 题意 Write a function that takes a string as input and returns the string reversed. 编写一个将字符串作为输入的函数,并返回反转的字符串。 ```python Example: Given s = "hello", return "olleh". ``` ### 思路 ```python class Solution(object): def reverseString(s...

    阅读全文>>

2018年4月15日 23:28 作者:nancy 分类:[LeetCode] 1383

125. Valid Palindrome [Easy] [String]

    ### 题意 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。 Note: For the purpose of this problem, we define empty string as valid palindrome....

    阅读全文>>

2018年4月14日 21:16 作者:nancy 分类:[LeetCode] 1250

67. Add Binary [Easy] [String]

    ### 题意   Given two binary strings, return their sum (also a binary string). 给定两个二进制字符串,返回他们的和(用二进制表示)。 The input strings are both non-empty and contains only characters 1 or 0. 输入为非空字符串且只包含数字 1 和 0。 Example 1: ```python Input: a = "...

    阅读全文>>

2018年4月13日 19:55 作者:nancy 分类:[LeetCode] 1302