leetcode 2180 easy

Leetcode刷题指南

## 1. 数据结构 ### 1.1 数组 - **循环数组问题**:把数组扩大为两倍即可,但不是真的扩大两倍,而是通过索引取模的方式 ### 1.2 链表 链表可以通过引入虚拟头节点 `ListNode *dummy = new ListNode{-1, nullptr}` 来极大简化 0. ** ......
Leetcode 指南

leetcode 17. 电话号码的字母组合

## 递归 自己写了个递归的算法 ```java class Solution { public List letterCombinations(String digits) { List resList = recursion(digits); return resList; } public L ......
电话号码 字母 leetcode 号码 电话

Leetcode 2352. 相等行列对

### 题目: 给你一个下标从 `0` 开始、大小为 `n x n` 的整数矩阵 `grid` ,返回满足 `R~i~` 行和 `C~j~` 列相等的行列对 `($$R_i$$, C~j~)` 的数目。 如果行和列以相同的顺序包含相同的元素(即相等的数组),则认为二者是相等的。 ### 难度:简单 ......
行列 Leetcode 2352

leetcode 15. 三数之和

## 暴力法 暴力解法总是最直接能想到的解法。 ```java NA ``` ## 双指针法 贴一个评论区看到的解法 ```java class Solution { //定义三个指针,保证遍历数组中的每一个结果 //画图,解答 public List> threeSum(int[] nums) { ......
之和 leetcode 15

Leetcode Hot 100 & 49. Group Anagrams

写在前面: 不知不觉已经研二下了,既然选择以后走AI这条路,不可避免地也得刷一刷leetcode题目,因为招聘的时候笔试总是要用到的。首先刷一刷leetcode的hot 100题,好记性赶不上烂笔头,记录下来在写这些算法题中的收获给自己看。 参考资料: 考点:哈希 & [题干] 这题没做出来,第一次 ......
Leetcode Anagrams Group Hot 100

[LeetCode] 2352. Equal Row and Column Pairs

Given a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal. A row and column pair is co ......
LeetCode Column Equal Pairs 2352

[LeetCode] 1347. Minimum Number of Steps to Make Two Strings Anagram 制造字母异位词的最小步骤数

You are given two strings of the same length `s` and `t`. In one step you can choose **any character** of `t` and replace it with **another character* ......
字母 LeetCode 步骤 Anagram Minimum

leetcode-图论总结

此文总结一下常见图论算法,代码可以为后续遇见类似题目提供参考: 1. 图的表示: 邻接矩阵:可通过创建数组得到 邻接表:我个人喜欢通过LinkedList<int[]>[] graph = new LinkedList[n];得到。 Edge List:同样可以通过LinkedList<int[]> ......
leetcode

leetcode-滑动窗口总结

滑动窗口是我在刷题时感觉比较困难的部分,简单做一个总结,防止之后又忘了: 一般模板如下: // 注意:java 代码由 chatGPT🤖 根据我的 cpp 代码翻译,旨在帮助不同背景的读者理解算法逻辑。 // 本代码还未经过力扣测试,仅供参考,如有疑惑,可以参照我写的 cpp 代码对比查看。 /* ......
leetcode

Leetcode 2460. 对数组执行操作

### 题目: 给你一个下标从 **0** 开始的数组 `nums` ,数组大小为 `n` ,且由 **非负** 整数组成。 你需要对数组执行 `n - 1` 步操作,其中第 `i` 步操作(从 **0** 开始计数)要求对 `nums` 中第 `i` 个元素执行下述指令: - 如果 `nums[i ......
数组 Leetcode 2460

[LeetCode] 2460. Apply Operations to an Array

You are given a 0-indexed array nums of size n consisting of non-negative integers. You need to apply n - 1 operations to this array where, in the ith ......
Operations LeetCode Apply Array 2460

LeetCode 669. 修剪二叉搜索树

#### 思路 - 遍历所有节点,如果当前节点不在所给区间里,删除该点;否则 - 如果该点要被删除,将其左右子树其中之一提上来即可 - 根节点位于左右子树取值区间的中间,如果该点要被删除,那么一定存在不满足要求的子树,不可能两棵子树同时保留 #### 代码 ```c class Solution { ......
LeetCode 669

[LeetCode] 1346. Check If N and Its Double Exist 检查整数及其两倍数是否存在

Given an array `arr` of integers, check if there exist two indices `i` and `j` such that : - `i != j` - `0 这道题给了一个整型数组,让检测是否有一个数字和其倍数同时存在的情况。一看到这道题博主就 ......
倍数 整数 LeetCode Double Check

LeetCode 周赛 348(2023/06/05)数位 DP 模板学会了吗

> **本文已收录到 [AndroidFamily](https://github.com/pengxurui/AndroidFamily),技术和职场问题,请关注公众号 [彭旭锐] 加入知识星球提问!** - 往期回顾:[LeetCode 单周赛第 347 场 · 二维空间上的 LIS 最长递增子 ......
数位 LeetCode 模板 2023 348

Leetcode 2517. 礼盒的最大甜蜜度

### 题目: 给你一个正整数数组 `price` ,其中 `price[i]` 表示第 `i` 类糖果的价格,另给你一个正整数 `k` 。 商店组合 `k` 类 不同 糖果打包成礼盒出售。礼盒的 **甜蜜度** 是礼盒中任意两种糖果 **价格** 绝对差的最小值。 返回礼盒的 **最大** 甜蜜度 ......
礼盒 Leetcode 2517

Leetcode 1156. 单字符重复子串的最大长度

### 题目: 如果字符串中的所有字符都相同,那么这个字符串是单字符重复的字符串。 给你一个字符串 `text`,你只能交换其中两个字符一次或者什么都不做,然后得到一些单字符重复的子串。返回其中最长的子串的长度。 ### 难度:中等 #### 示例1: ``` 输入:text = "ababa" 输 ......
单字 长度 Leetcode 1156

LeetCode 450. 删除二叉搜索树中的节点

```c class Solution { public: TreeNode* deleteNode(TreeNode* root, int key) { del(root,key); return root; } void del(TreeNode* &root,int key) { if(!ro ......
节点 LeetCode 450

LeetCode 538. 把二叉搜索树转换为累加树

```c class Solution { public: void dfs(TreeNode* root,int &sum)//从大到小遍历所有节点 { if(!root) return; dfs(root->right,sum); sum+=root->val; root->val=sum; d ......
LeetCode 538

[LeetCode] 1345. Jump Game IV 跳跃游戏之四

Given an array of integers `arr`, you are initially positioned at the first index of the array. In one step you can jump from index `i` to index: - `i ......
LeetCode 1345 Jump Game IV

LeetCode 501. 二叉搜索树中的众数

``` class Solution { public: vector res; int cnt=0; int find(TreeNode* root,int val)//返回当前子树值为val的个数 { if(!root) return 0; return find(root->left,val) ......
LeetCode 501

Easy Music 说明文档

1.顶部搜索栏: 功能描述: 进行歌曲搜索 状态描述: 点击时展开搜索栏,输入歌手名/歌曲名时,进行列表筛选。 2.菜单栏: 功能描述: 打开菜单 状态描述: 点击时从左边弹出菜单栏。 3.下一首: 位置:底部,右1; 功能描述: 点击切换下一曲;开启软件初始状态时,点击播放最后一首,并Toast弹 ......
文档 Music Easy

[LeetCode] 2101. Detonate the Maximum Bombs

You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the ......
LeetCode Detonate Maximum Bombs 2101

LeetCode.螺旋矩阵问题

## LeetCode54 螺旋矩阵 ![image-20220708211259147](https://img2023.cnblogs.com/blog/2896522/202306/2896522-20230602225454384-849616346.png) ### 思路 就是说,**给我 ......
矩阵 螺旋 LeetCode 问题

leetcode2352哈希表的键可以是一个容器等类型

map<vector<int>,int>cnt;//用于存储每个行向量出现的次数 for(auto row:grid){//直接遍历行向量 cnt[row]++; } for(int i=0;i<n;++i){ vector<int>arr; for(int j=0;j<n;++j){//存储列向量 ......
容器 leetcode 类型 2352

leetcode2352二维vector的操作

对于二维vector有分外层和内层: 当初始化指定了外层大小(行数)时,添加元素写法: 错误写法:不能使用[] vector<vector<int>>v(3);//指定外层数目 for(int i=0;i<3;++i){ for(int j=0;j<n;++j){ v[i][j]=0; } } 正确 ......
leetcode vector 2352

Leetcode 2559. 统计范围内的元音字符串数

### 题目: 给你一个下标从 `0` 开始的字符串数组 `words` 以及一个二维整数数组 `queries` 。 每个查询 `queries[i] = [l, r]` 会要求我们统计在 `words` 中下标在 `l` 到 `r` 范围内(包含 这两个值)并且以元音开头和结尾的字符串的数目。 ......
元音 字符串 字符 Leetcode 范围

leetcode 1393 股票的资本损益

leetcode 1393 股票的资本损益 select p1.stock_name, (p2.price - p1.price) as capital_gain_loss from ( select s1.stock_name, s1.operation, sum(s1.price) as pri ......
损益 leetcode 资本 股票 1393

LeetCode 236_ 二叉树的最近公共祖先

```c class Solution { public: vector path1,path2; bool dfs(TreeNode* root,TreeNode* p,vector& path) { if(!root) return false; if(root==p||dfs(root->le ......
祖先 LeetCode 236

LeetCode235. 二叉搜索树的最近公共祖先

```c class Solution { public: TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) { if(p->valval&&q->valval) return lowestCommonA ......
祖先 LeetCode 235

Easy-Es

使用过Spring Data操作ES的小伙伴应该有所了解,它只能实现一些非常基本的数据管理工作,一旦遇到稍微复杂点的查询,基本都要依赖ES官方提供的RestHighLevelClient,Spring Data只是在其基础上进行了简单的封装。最近发现一款更优雅的ES ORM框架Easy-Es,使用它 ......
Easy-Es Easy Es