## [LeetCode] 87. Scramble String 搅乱字符串

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": great / \ gr eat / \ / \ g r e at / \ a t To scramble the string, we may ch…

## [LeetCode] 87. Scramble String 爬行字符串

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": great / \ gr eat / \ / \ g r e at / \ a t To scramble the string, we may ch…

## Leetcode：003 无重复字符串

Leetcode:003 无重复字符串 关键点:给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度.示例 1:输入: "abcabcbb"输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3.示例 2:输入: "bbbbb"输出: 1解释: 因为无重复字符的最长子串是 "b",所以其长度为 1.示例 3:输入: "pwwkew"输出: 3解释: 因为无重复字符的最长子串是…

## LeetCode（43）：字符串相乘

Medium! 题目描述: 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式. 示例 1: 输入: num1 = "2", num2 = "3" 输出: "6" 示例 2: 输入: num1 = "123", num2 = "456" 输出: "56088" 说明: num1 和 num2 的长度小于110.…

## LeetCode初级算法的Python实现--排序和搜索、设计问题、数学及其他

LeetCode初级算法的Python实现--排序和搜索.设计问题.数学及其他 1.排序和搜索 class Solution(object): # 合并两个有序数组 def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify…

## LeetCode（87）：扰乱字符串

Hard! 题目描述: 给定一个字符串 s1,我们可以把它递归地分割成两个非空子字符串,从而将其表示为二叉树. 下图是字符串 s1 = "great" 的一种可能的表示形式. great / \ gr eat / \ / \ g r e at / \ a t 在扰乱这个字符串的过程中,我们可以挑选任何一个非叶节点,然后交换它的两个子节点. 例如,如果我们挑选非叶节点 "gr" ,交换它的两个子节点,将会产生扰乱字符串 "rgeat" . rgea…

## [leetcode]87. Scramble String字符串树形颠倒匹配

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": great / \ gr eat / \ / \ g r e at / \ a t To scramble the string, we may ch…

## leetCode 87.Scramble String （拼凑字符串） 解题思路和方法

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": great / \ gr eat / \ / \ g r e at / \ a t To scramble the string, we may ch…

## [LeetCode] Repeated Substring Pattern 重复子字符串模式

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 exceed 100…

## [LeetCode] Bold Words in String 字符串中的加粗单词

Given a set of keywords words and a string S, make all appearances of all keywords in S bold. Any letters between <b> and </b> tags become bold. The returned string should use the least number of tags possible, and of course the tags should fo…

## [LeetCode] 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 spe…

## [LeetCode] Reverse String II 翻转字符串之二

Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them. If there are less than 2k but greater than or eq…

## LeetCode（8）：字符串转整数（atoi）

Medium! 题目描述: 实现 atoi,将字符串转为整数. 在找到第一个非空字符之前,需要移除掉字符串中的空格字符.如果第一个非空字符是正号或负号,选取该符号,并将其与后面尽可能多的连续的数字组合起来,这部分字符即为整数的值.如果第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数. 字符串可以在形成整数的字符后面包括多余的字符,这些字符可以被忽略,它们对于函数没有影响. 当字符串中的第一个非空字符序列不是个有效的整数:或字符串为空:或字符串仅包含空白字符时,则不进行转换.…

## LeetCode ZigZag Conversion（将字符串排成z字型）

class Solution { public: string convert(string s, int nRows) { string a=""; int len=s.length(); ) return s; //只有n个,不足一个周期||排成一行 -); //teams个完整的周期 -); //最后一个不足完整周期的元素数 ,i=,j=; ;i<nRows;i++){ k=i; ;j<teams;j++){ a+=s[k]; && i!=nRows-…

## 从源码角度看 PHP 字符串类型转换

PHP 的类型转换是比较方便的,但是越是容易使用的东西,底层的实现越是复杂,而且在使用中像我这样的新手也往往不清楚转换后的结果到底是什么.有时候,对于 Java 这种强类型的语言,使用的时候需要强制进行转换,这样多半转换后的结果是可以预料的,至少自己是想这么做的. 通过实例看转换 写个关于 PHP 类型转换的代码测试一下吧,看看大家是否能知道输出结果.把 各种数据类型 都转换为 字符串类型试试. <?php \$var = false; echo '\$var:', \$var, "\r\n&q…

## [LeetCode] 767. Reorganize String 重构字符串

Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same. If possible, output any possible result.  If not possible, return the empty string. Example 1: Input: S = "aab" Out…

## [LeetCode] 394. Decode String 解码字符串

Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume th…

## [LeetCode] 567. Permutation in String 字符串中的全排列

Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutations is the substring of the second string. Example 1: Input:s1 = "ab" s2 = "eidbaooo"…

## LeetCode 459. 重复的子字符串(Repeated Substring Pattern)

459. 重复的子字符串 459. Repeated Substring Pattern 题目描述 给定一个非空的字符串,判断它是否可以由它的一个子串重复多次构成.给定的字符串只含有小写英文字母,并且长度不超过 10000. LeetCode459. Repeated Substring Pattern 示例 1: 输入: "abab" 输出: True 解释: 可由子字符串 "ab" 重复两次构成. 示例 2: 输入: "aba" 输出: Fa…

## LeetCode 680. 验证回文字符串 Ⅱ(Valid Palindrome II) 1

680. 验证回文字符串 Ⅱ 680. Valid Palindrome II 题目描述 给定一个非空字符串 s,最多删除一个字符.判断是否能成为回文字符串. 每日一算法2019/5/4Day 1LeetCode680. Valid Palindrome II 示例 1: 输入: "aba" 输出: True 示例 2: 输入: "abca" 输出: True 解释: 你可以删除c字符. 注意: 字符串只包含从 a-z 的小写字母.字符串的最大长度是 50000.…