leetcode刷题题目分类

字符串

1.KMP字符串匹配 https://leetcode.com/problems/implement-strstr/description/

2.句子逆序 leetcode151

3.判断一个树是否是另一个树的子树  leetcode242

括号

1.是否是有效括号 leetcode20

2.生成有效的括号序列 leetcode22

3.寻找字符串中最长有效括号序列长度 leetcode32

4.去除无效括号 leetcode301

5.添加括号的不同种方法 leetcode241

原文地址:https://www.cnblogs.com/xiaobaituyun/p/8439634.html

时间: 2024-10-10 09:19:35

leetcode刷题题目分类的相关文章

LeetCode刷题(一):Two Sum

今天开始在LeetCode刷题,第一题为"两数之和(Two Sum)",整体来讲这一题难度是比较低的,但还是在这个过程中遇到一些问题,以下主要记录出现的一些问题. 这个题目比较容易想到的方法便是穷举了,很暴力但也很直接,需要注意的一点便是向量库Vector,自己也是前一阵子开始学数据结构才知道有这个库(有的也称为容器),定义计算数组长度用的方法是size()而不是length(),官方解答给的是length(),不知道是不是没有注意到还是因为他用的代码是Java(本人不了解Java),

leetcode 刷题之路 63 Binary Tree Zigzag Level Order Traversal

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / 9 20 / 15 7 return its zig

【leetcode刷题笔记】Remove Duplicates from Sorted Array II

Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For example,Given sorted array A = [1,1,1,2,2,3], Your function should return length = 5, and A is now [1,1,2,2,3]. 题解: 设置两个变量:右边kepler和前向游标forward.如果当前kepeler所指的元素和

【leetcode刷题笔记】Set Matrix Zeroes

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 题解:因为题目要求原地算法,所以我们只能利用矩阵第一行和第一列存放置零信息. 首先遍历第一行和第一列,看他们是否需要全部置零,用两个变量first_column_zero和first_row_zero来记录: 遍历矩阵,如果某个位置matrix[i][j]出现了0,就把matrix[i][0]和Matrix[0

leetcode 刷题之路 92 Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 一个台阶总共有n级,如果一次可以跳1级,也可以跳2级,求总共有多少总跳法. 分析: 一次最多只能跳两级,那么对于第n级(n>=2)台阶,显然只能从第n-1级跳一级到达或

【leetcode刷题笔记】Substring with Concatenation of All Words

You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters. For example, given:S: "b

【leetcode刷题笔记】Validate Binary Search Tree

Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys

【leetcode刷题笔记】N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of

【leetcode刷题笔记】Valid Number

Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true 题解:题目不难,就是有点麻烦,要注意的地方很多,总结一下: 前面和后面的空格要用s.trim()去掉: 前导的'+'和'-'号需要忽略: