频率leetcode 895

Leetcode 209. 长度最小的子数组(Minimum size subarray sum)

[题目链接](https://leetcode.cn/problems/minimum-size-subarray-sum) 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其和 ≥ target 的长度最小的 连续子数组 [numsl, numsl+1, ..., ......
数组 长度 Leetcode subarray Minimum

LeetCode--1039

Smiling & Weeping 我总是躲在梦与季节的身处, 听花与黑夜唱尽梦魇, 唱尽繁华,唱断所有记忆的来路。 题目链接:1039. 多边形三角剖分的最低得分 - 力扣(LeetCode) 题目描述: 你有一个凸的 n 边形,其每个顶点都有一个整数值。给定一个整数数组 values ,其中 v ......
LeetCode 1039

Leetcode 977. 有序数组的平方(Squares of a sorted array)

[题目链接](https://leetcode.cn/problems/squares-of-a-sorted-array) 给你一个按**非递减顺序**排序的整数数组nums, 返回每个数字的平方组成的新数组, 要求也按**非递减顺序**排序. 示例 1: ``` 输入:nums = [-4,-1 ......
数组 Leetcode Squares sorted array

Leetcode 27. 移除元素(Remove Element)

[题目链接](https://leetcode.cn/problems/remove-element) 给你一个数组nums和一个值val, 你需要**原地**移除所有数值等于val的元素, 并返回移除后数组的新长度. 不要使用额外的数组空间, 你必须仅使用O(1)额外空间并**原地**修改输入数组 ......
Leetcode 元素 Element Remove 27

Leetcode167. 两数之和 II - 输入有序数组(双指针)

题目: [ 两数之和 II - 输入有序数组(双指针)](https://leetcode.cn/problems/two-sum-ii-input-array-is-sorted/description/) 给你一个下标从 1 开始的整数数组 numbers ,该数组已按 非递减顺序排列 ,请你从 ......
之和 数组 指针 Leetcode 167

LeetCode -- 827. 最大人工岛

题目大意:给一个邻接矩阵,问改变一个点后,最大连通块多大 对于这种连通块相关问题,一般的思路就是进行深搜和并查集,这里采用并查集维护连通块大小解法。 首先先初始化并查集,并进行连通块的合并;再对图中的0进行枚举,找到最大的连通块即可。 对(n * m)的二维点阵图常用技巧,二维转一维:点(i, j) ......
人工岛 人工 LeetCode 827

LeetCode从算法到算命—1281.整数的各位积和之差(20230809)

# 1281.整数的各位积和之差 ## 题目信息 给你一个整数 `n`,请你帮忙计算并返回该整数「各位数字之积」与「各位数字之和」的差。 **示例 1:** ``` 输入:n = 234 输出:15 解释: 各位数之积 = 2 * 3 * 4 = 24 各位数之和 = 2 + 3 + 4 = 9 结 ......
整数 算法 LeetCode 20230809 1281

有效的括号--LeetCode算法

不用map的解法 public boolean isValid(String s) { //输入的字符串为空,直接返回true if(s.isEmpty()) return true; //新建一个栈 Stack<Character> stack=new Stack<Character>(); // ......
括号 算法 LeetCode

Leetcode 704. 二分查找(Binary Search)

[题目链接](https://leetcode.cn/problems/binary-search) 给定一个n个元素有序的(升序)整型数组`nums`和一个目标值`target`, 写一个函数搜索`nums`中的`target`, 如果目标值存在返回下标, 否则返回`-1`。 示例 1: ``` ......
Leetcode Binary Search 704

LeetCode从算法到算命—1749.任意子数组和的绝对值的最大值

# 1749.任意子数组和的绝对值的最大值 ## 题目信息 给你一个整数数组 `nums` 。一个子数组 `[numsl, numsl+1, ..., numsr-1, numsr]` 的 **和的绝对值** 为 `abs(numsl + numsl+1 + ... + numsr-1 + nums ......
绝对值 最大值 数组 算法 LeetCode

使用golang解决LeetCode热题Hot100(1-10)

# 使用golang解决LeetCode热题Hot100 ## 1.两数之和 ### https://leetcode.cn/problems/two-sum/ #### 题目 给定一个整数数组 `nums` 和一个整数目标值 `target`,请你在该数组中找出 **和为目标值** *`targe ......
LeetCode golang Hot 100 10

Leetcode刷题记录本

# Leetcode刷题记录本 ### ID: 1 点击查看代码 1. 暴力破解法 ```python class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: in ......
Leetcode

leetcode:下一个排列

class Solution { public: void nextPermutation(vector<int>& nums) { int n=nums.size(); int i=n-2; while(i>=0 && nums[i]>=nums[i+1]){//从后向前,找到第一个降序的,一直升 ......
leetcode

LeetCode -- 127. 单词接龙

方法一:双向广搜 class Solution { public: int ladderLength(string beginWord, string endWord, vector<string>& wordList) { set<string> se; for(auto it : wordLis ......
接龙 单词 LeetCode 127

LeetCode 热题 100 之 240. 搜索二维矩阵 II

# 题目 编写一个高效的算法来搜索 m x n 矩阵 matrix 中的一个目标值 target 。该矩阵具有以下特性: 每行的元素从左到右升序排列。 每列的元素从上到下升序排列。 **示例一** ![image](https://img2023.cnblogs.com/blog/2204134/2 ......
矩阵 LeetCode 100 240 II

LeetCode 16. 3Sum Closest 双指针+排序

Given an integer array `nums` of length n and an integer `target`, find three integers in nums such that the sum is closest to `target`. Return the su ......
指针 LeetCode Closest 3Sum Sum

LeetCode从算法到算命—344.翻转字符串

# 344.翻转字符串 ## 题目信息 编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组 `s` 的形式给出。 不要给另外的数组分配额外的空间,你必须**[原地](https://baike.baidu.com/item/原地算法)修改输入数组**、使用 O(1) 的额外空间解决这 ......
字符串 算法 字符 LeetCode 344

LeetCode 周赛上分之旅 #38 结合排序不等式的动态规划

> ⭐️ **本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 \[彭旭锐] 和 [BaguTree Pro](https://www.mdnice.com/writing/85b28c4e60354865a423728e668fc570) 知识星球提问。** > > 学习数据 ......
不等式 LeetCode 之旅 动态 38

LeetCode 周赛上分之旅 # 37 多源 BFS 与连通性问题

> ⭐️ **本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 \[彭旭锐] 和 [BaguTree Pro](https://files.mdnice.com/user/3257/de950859-eb71-4821-a36b-bebe5cff500d.png) 知识星球提问 ......
LeetCode 之旅 问题 BFS 37

LeetCode从算法到算命—24.两两交换链表中的节点(0806)

# 24.两两交换链表中的节点 ## 题目信息 给你一个链表,两两交换其中相邻的节点,并返回交换后链表的头节点。你必须在不修改节点内部的值的情况下完成本题(即,只能进行节点交换)。 **示例 1:** ![image](https://img2023.cnblogs.com/blog/3083774 ......
节点 算法 LeetCode 0806 24

leetcode:括号生成

回溯的本质是穷举,穷举所有情况,这里有剪枝,只在有效情况下继续 class Solution { vector<string> res; string str; void backtracking(int left,int right){ if(left<0 || left>right) retur ......
括号 leetcode

Leetcode第357场周赛

https://leetcode.cn/contest/weekly-contest-357/ ## C 寻找不安全路径 以所有小偷点为源点,跑多源点BFS,求出每个点到最近小偷点的曼哈顿距离,记为w[i, j] 二分答案Mid,只允许走w[i, j] >= mid的点,从源店跑DFS/BFS,看是 ......
Leetcode 357

【LeetCode剑指offer#06】实现pow函数、计算x的平方根

### 实现pow函数 实现 [pow(*x*, *n*)](https://www.cplusplus.com/reference/valarray/pow/) ,即计算 `x` 的整数 `n` 次幂函数(即,`xn` )。 **示例 1:** ``` 输入:x = 2.00000, n = 10 ......
平方根 函数 LeetCode offer pow

[LeetCode] 1351. Count Negative Numbers in a Sorted Matrix 统计有序矩阵中的负数

Given a `m x n` matrix `grid` which is sorted in non-increasing order both row-wise and column-wise, return *the number of **negative** numbers in* `g ......
负数 矩阵 LeetCode Negative Numbers

LeetCode从算法到算命—每日一题(0805)

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

LeetCode 206 反转链表,LeetCode 92反转链表Ⅱ

206. 反转链表 给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。 示例 1: 输入:head = [1,2,3,4,5] 输出:[5,4,3,2,1] 示例 2: 输入:head = [1,2] 输出:[2,1] 示例 3: 输入:head = [] 输出:[] 提示: 链表中 ......
LeetCode 206

LeetCode -- 722. 删除注释

利用双指针来进行删除操作 class Solution { public: vector<string> removeComments(vector<string>& source) { string str; for(auto it : source) str += it + "'"; int n ......
注释 LeetCode 722

LeetCode 3. 无重复字符的最长子串

``` class Solution { public: int res=0; int lengthOfLongestSubstring(string s) { int n=s.size (); if(!n) return 0; bool st[128]={false}; for(int j=0,i ......
字符 LeetCode

LeetCode从算法到算命—每日一题(0804)

# 980.不同路径III ## 题目信息 在二维网格 `grid` 上,有 4 种类型的方格: - `1` 表示起始方格。且只有一个起始方格。 - `2` 表示结束方格,且只有一个结束方格。 - `0` 表示我们可以走过的空方格。 - `-1` 表示我们无法跨越的障碍。 返回在四个方向(上、下、左 ......
算法 LeetCode 0804