87. Scramble String 题目 Given a string s1, we may represent it as a binary tree by partitioning it to two non-e…
分类:LeetCode
72. Edit Distance
72. Edit Distance 题目 要想把字符串S1变成S2,可以经过若干次下列原子操作: 1.删除一个字符 2.增加一个字符 3.更改一个字符 字符串S1和S2的编辑距离定义为从S1变成S2所需要原子操作的最少次…
[LeetCode] Repeated DNA Sequences 求重复的DNA序列
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAA…
LeetCode 144. Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes’ values. For example:Given binary tree {…
65. Valid Number-Leetcode
处理字符串类型判断的常见问题 首位空格的处理 //相比较只对字符串的小标进行移动来处理非空序列,这种直接删除的方式后期判断能更快,而且省掉了记录字符首尾下标的麻烦 while(s[0]==' ') s.erase(0,1…
[剑指offer] 树的子结构
题目描述 输入两棵二叉树A,B,判断B是不是A的子结构。(ps:我们约定空树不是任意一个树的子结构) 解题思路 递归思想,如果根节点相同则递归调用IsSubtree(),如果根节点不相同,则判断root1的左子树和roo…
[LeetCode] Two Sum III - Data structure design 两数之和之三 - 数据结构设计
Design and implement a TwoSum class. It should support the following operations:add and find. add ̵…
[LeetCode] Reverse Words in a String II 翻转字符串中的单词之二
Given an input string , reverse the string word by word. Example: Input: ["t","h","e"," ","s…
[LeetCode] Equal Tree Partition 划分等价树
Given a binary tree with n nodes, your task is to check if it’s possible to partition t…
[LeetCode] Binary Search 二分搜索法
Given a sorted (in ascending order) integer array nums of n elements and …
LeetCode 222 Count Complete Tree Nodes
题目描述 Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipe…
LeetCode | Permutation Sequence(找到全排列中的第k个排列)
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of …