leetcode tarjan 341 lca

[LeetCode] 1870. Minimum Speed to Arrive on Time

You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n tr ......
LeetCode Minimum Arrive Speed 1870

代码随想录算法训练营第一天| LeetCode 704. 二分查找、LeetCode 27. 移除元素

704. 二分查找 题目链接:https://leetcode.cn/problems/binary-search/ 视频链接:https://www.bilibili.com/video/BV1fA4y1o715 文章讲解:https://programmercarl.com/0704.%E4%B ......
LeetCode 随想录 训练营 随想 算法

LeetCode 560. 和为 K 的子数组

``` class Solution { public: int subarraySum(vector& nums, int k) { int n=nums.size(),res=0; vector s(n+1,0); unordered_map hash;//记录端点i之前所有前缀和的出现情况 f ......
数组 LeetCode 560

Leetcode437. 路径总和 III

``` /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), ......
总和 路径 Leetcode 437 III

[LeetCode] 2013. Detect Squares

You are given a stream of points on the X-Y plane. Design an algorithm that: Adds new points from the stream into a data structure. Duplicate points a ......
LeetCode Squares Detect 2013

2167 - 树的公共祖先(LCA)

题目描述 给定一棵树和两个不同的结点,求出他们最近的公共祖先父结点。 已知该树有 n 个结点,标号 1..n 。 输入 第 1 行输入一个整数 nn,代表结点数量(n≤100) 第 2 行输入两个整数 x,yx,y,表示需要计算的结点; 以下 n−1 行,每行两个整数 a 和 b,表示 a 的父结点 ......
祖先 2167 LCA

go刷题Leetcode,生成文件夹与go文件模板

## go生成文件夹与模板 ### 起因 以前是用C/C++刷Leetcode时,将多个C/CPP文件放在同一个目录下,没有出任何问题,但是换成Go语言刷题。 在一个目录下创建多个go文件,每个文件都是以下 ```go package main func main(){ } ``` 在vscode下 ......
文件 文件夹 Leetcode 模板

leetcode1448好节点深刻理解DFS+BFS

DFS 没有返回值 max在递归时要慎重用引用,因为在回溯时可能不能改变max; 因为节点的值可能有负数,所以最大值从根节点开始,根节点一定是好节点。 int goodNum=0; void dfs(TreNode* root,int max){ if(!root)return ; if(root- ......
节点 leetcode 1448 DFS BFS

LeetCode 热题 100 之 53. 最大子数组和

# 题目 给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 子数组 是数组中的一个连续部分。 **示例 1:** 输入:nums = [-2,1,-3,4,-1,2,1,-5,4] 输出:6 解释:连续子数组 [4,-1,2,1] 的和最大, ......
数组 LeetCode 100 53

LeetCode 406. 根据身高重建队列

``` class Solution { public: struct node { int val; int pre; node* next; node(int a,int b,node* c) { val=a; pre=b; next=c; } }; void insert(node* &hea ......
队列 LeetCode 身高 406

P3379 【模板】最近公共祖先(LCA)

## [$P3379$ 【模板】最近公共祖先($LCA$)](https://www.luogu.com.cn/problem/P3379) #### $LCA$常见的四种求法 ![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai ......
祖先 模板 P3379 3379 LCA

[LeetCode] 2208. Minimum Operations to Halve Array Sum

You are given an array nums of positive integers. In one operation, you can choose any number from nums and reduce it to exactly half the number. (Not ......
Operations LeetCode Minimum Halve Array

leetcode第354场周赛 2 - 双指针

[题目传送门](https://leetcode.cn/contest/weekly-contest-354/) # [2779. 数组的最大美丽值](https://leetcode.cn/problems/maximum-beauty-of-an-array-after-applying-ope ......
指针 leetcode 354

LeetCode 热题 100 之 21. 合并两个有序链表

# 题目 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 **示例 1:** 输入:l1 = [1,2,4], l2 = [1,3,4] 输出:[1,1,2,3,4,4] **示例 2:** 输入:l1 = [], l2 = [] 输出:[] **示 ......
LeetCode 两个 100 21

LeetCode 热题 100 之 560. 和为 K 的子数组.md

# 题目 给你一个整数数组 nums 和一个整数 k ,请你统计并返回 该数组中和为 k 的连续子数组的个数 。 **示例 1:** 输入:nums = [1,1,1], k = 2 输出:2 **示例 2:** 输入:nums = [1,2,3], k = 3 输出:2 **提示:** 1 int ......
数组 LeetCode 100 560 md

【模板】最近公共祖先(LCA)

posted on 2021-08-04 14:22:40 | under 学术 | [source](https://www.luogu.com.cn/blog/_post/357449) LCA,Least Common Ancestors,最近公共祖先。 倍增。 首先预处理出数组 $d_i$ ......
祖先 模板 LCA

[Leetcode Weekly Contest]355

链接:[LeetCode](https://leetcode-cn.com/contest/weekly-contest-355/) ## [Leetcode]6921. 按分隔符拆分字符串 给你一个字符串数组 words 和一个字符 separator ,请你按 separator 拆分 word ......
Leetcode Contest Weekly 355

LeetCode 热题 100 之 438. 找到字符串中所有字母异位词

# 题目 给定两个字符串 s 和 p,找到 s 中所有 p 的 异位词 的子串,返回这些子串的起始索引。不考虑答案输出的顺序。 异位词 指由相同字母重排列形成的字符串(包括相同的字符串)。 **示例 1:** 输入: s = "cbaebabacd", p = "abc" 输出: [0,6] 解释: ......
字符串 字母 字符 LeetCode 100

LeetCode 热题 100 之 3. 无重复字符的最长子串

# 题目 给定一个字符串 s ,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: s = "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 示例 2: 输入: s = "bbbbb" 输出: 1 解释: 因为无重复字符的最长子串 ......
字符 LeetCode 100

LeetCode 399. 除法求值

``` class Solution { public: vector calcEquation(vector>& equations, vector& values, vector>& queries) { unordered_set node;//记录所有节点 unordered_map> g; ......
除法 LeetCode 399

LeetCode 周赛上分之旅 #34 按部就班地解决动态规划问题

> ⭐️ **本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 [彭旭锐] 和 [BaguTree Pro] 知识星球提问。** > > 学习数据结构与算法的关键在于掌握问题背后的算法思维框架,你的思考越抽象,它能覆盖的问题域就越广,理解难度也更复杂。在这个专栏里,小彭与你分享 ......
按部就班 LeetCode 之旅 动态 问题

LeetCode 周赛上分之旅 #35 两题坐牢,菜鸡现出原形

> ⭐️ **本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 [彭旭锐] 和 [BaguTree Pro] 知识星球提问。** > > 学习数据结构与算法的关键在于掌握问题背后的算法思维框架,你的思考越抽象,它能覆盖的问题域就越广,理解难度也更复杂。在这个专栏里,小彭与你分享 ......
原形 LeetCode 之旅 35

leetcode第109场双周赛

[题目传送门](https://leetcode.cn/contest/biweekly-contest-109/) # [6931. 访问数组中的位置使分数最大](https://leetcode.cn/problems/visit-array-positions-to-maximize-scor ......
leetcode 109

LeetCode 438. Find All Anagrams in a String 滑动窗口

Given two strings `s` and `p`, return an array of all the start indices of `p`'s anagrams in s. You may return the answer in any order. An Anagram is ......
LeetCode Anagrams String Find 438

leetcode第 109 场双周赛

## [6930. 检查数组是否是好的 - 力扣(LeetCode)](https://leetcode.cn/problems/check-if-array-is-good/) **首先判断数组长度是不是最大值 + 1, 然后排个序,判断0到n - 2是不是都是1到最大值的一个排列,满足这些返回t ......
leetcode 109

【优先队列】【堆排序实现优先队列】[1054. 距离相等的条形码](https://leetcode.cn/problems/distant-barcodes/)

#### 【优先队列】【堆排序实现优先队列】[1054. 距离相等的条形码](https://leetcode.cn/problems/distant-barcodes/) 在一个仓库里,有一排条形码,其中第 i 个条形码为 barcodes[i]。 请你重新排列这些条形码,使其中任意两个相邻的条形 ......

[LeetCode] 894. All Possible Full Binary Trees

Given an integer n, return a list of all possible full binary trees with n nodes. Each node of each tree in the answer must have Node.val == 0. Each e ......
LeetCode Possible Binary Trees Full

LeetCode 3. Longest Substring Without Repeating Characters 滑动窗口

Given a string `s`, find the length of the longest substring without repeating characters. ## Solution 用一个 $dict$ 来映射字符的次数。然后用 $left$, $right$ 来决定wind ......

leetcode-2582-easy

Pass the Pillow ``` There are n people standing in a line labeled from 1 to n. The first person in the line is holding a pillow initially. Every secon ......
leetcode 2582 easy

Leetcode394. 字符串解码

``` class Solution { public: string dfs(string s,int &idx) { string str; while(idx'0'&&s[idx]='0'&&s[idx]<='9') num+=s[idx++]; if(s[idx]=='[') { int c ......
字符串 字符 Leetcode 394