rectangle leetcode number ships

图-邻接表-leetcode207

你这个学期必须选修 ​​numCourses​​​ 门课程,记为 ​​0​​​ 到 ​​numCourses - 1​​ 。 在选修某些课程之前需要一些先修课程。 先修课程按数组 ​​prerequisites​​ 给出,其中 ​​prerequisites[i] = [ai, bi]​​ ,表示如 ......
leetcode 207

[LeetCode] 2679. Sum in a Matrix

You are given a 0-indexed 2D integer array nums. Initially, your score is 0. Perform the following operations until the matrix becomes empty: From eac ......
LeetCode Matrix 2679 Sum in

LeetCode/公平分发饼干

给你一个整数数组 cookies ,其中 cookies[i] 表示在第 i 个零食包中的饼干数量。 另给你一个整数 k 表示等待分发零食包的孩子数量,所有 零食包都需要分发。在同一个零食包中的所有饼干都必须分发给同一个孩子,不能分开。 分发的 不公平程度 定义为单个孩子在分发过程中能够获得饼干的最 ......
饼干 LeetCode

LeetCode 周赛 352(2023/07/02)一场关于子数组的专题周赛

> **本文已收录到 [AndroidFamily](https://github.com/pengxurui/AndroidFamily),技术和职场问题,请关注公众号 [彭旭锐] 和 [BaguTree Pro] 知识星球提问。** - 往期回顾:[LeetCode 单周赛第 350 场 · 滑 ......
数组 LeetCode 专题 2023 352

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

#题目链接:[LeetCode 538. 把二叉搜索树转换为累加树](https://leetcode.cn/problems/convert-bst-to-greater-tree/) ##题意: **给出二叉 搜索 树的根节点,该树的节点值各不相同,请你将其转换为累加树(Greater Sum ......
LeetCode 538

LeetCode 108. 将有序数组转换为二叉搜索树

#题目链接:[LeetCode 108. 将有序数组转换为二叉搜索树](https://leetcode.cn/problems/convert-sorted-array-to-binary-search-tree/) ##题意: **给你一个整数数组 nums ,其中元素已经按 升序 排列,请你将 ......
数组 LeetCode 108

LeetCode 669. 修剪二叉搜索树

#题目链接:[LeetCode 669. 修剪二叉搜索树](https://leetcode.cn/problems/trim-a-binary-search-tree/) ##题意: **给你二叉搜索树的根节点 root ,同时给定最小边界low 和最大边界 high。通过修剪二叉搜索树,使得所有 ......
LeetCode 669

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

#题目链接:[LeetCode 450. 删除二叉搜索树中的节点](https://leetcode.cn/problems/delete-node-in-a-bst/) ##题意: **给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的 key 对应的节点,并保证二叉搜索树 ......
节点 LeetCode 450

IDEA安装leetcode插件

1.在idea的Settings-Plugins-BrowseRepositories搜索leetcode。如图: 安装完成后,重启idea。 2.Idea的Tools下出现leetcode plugin: 设置leetcode官网的登录名和密码,设置TempFilePath这里设置为新建项目的路径 ......
插件 leetcode IDEA

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

#题目链接:[LeetCode 235. 二叉搜索树的最近公共祖先](https://leetcode.cn/problems/lowest-common-ancestor-of-a-binary-search-tree/description/) ##题意: **给定一个二叉搜索树, 找到该树中两 ......
祖先 LeetCode 235

LeetCode 701. 二叉搜索树中的插入操作

#题目链接:[LeetCode 701. 二叉搜索树中的插入操作](https://leetcode.cn/problems/insert-into-a-binary-search-tree/) ##题意: **给定二叉搜索树(BST)的根节点 root 和要插入树中的值 value ,将值插入二叉 ......
LeetCode 701

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

#题目链接:[LeetCode 236. 二叉树的最近公共祖先](https://leetcode.cn/problems/lowest-common-ancestor-of-a-binary-tree/description/) ##题意: **给定一个二叉树, 找到该树中两个指定节点的最近公共祖 ......
祖先 LeetCode 236

(Leetcode)746

```java // 方式一:第一步不支付费用 class Solution { public int minCostClimbingStairs(int[] cost) { int len = cost.length; int[] dp = new int[len + 1]; // 从下标为 0 ......
Leetcode 746

leetcode 26. 删除有序数组中的重复项

## 直接法 ```java public int removeDuplicates(int[] nums) { if (nums == null) { return -1; } boolean start = false; int nextIndex = 1; for (int i = 1; i ......
数组 leetcode 26

leetcode 22. 括号生成

## 暴力枚举 ```java class Solution { public List generateParenthesis(int n) { List list = getAll(2 * n); List result = new ArrayList(); for (String item : ......
括号 leetcode 22

LeetCode 152. 乘积最大子数组

``` class Solution { public: static const int N=20010; int f[N],g[N]; int maxProduct(vector& nums) { int n=nums.size(); int res=nums[0]; f[0]=g[0]=num ......
乘积 数组 LeetCode 152

【leetcode】【剑指 Offer 06】【从尾到头打印链表】

# c++ ## 第一个方法 ```c++ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) ......
leetcode Offer

【LeetCode】矩阵中的和

``` 给你一个下标从 0 开始的二维整数数组 nums 。一开始你的分数为 0 。你需要执行以下操作直到矩阵变为空: 矩阵中每一行选取最大的一个数,并删除它。如果一行中有多个最大的数,选择任意一个并删除。 在步骤 1 删除的所有数字中找到最大的一个数字,将它添加到你的 分数 中。 请你返回最后的 ......
矩阵 LeetCode

【笔试实战】LeetCode题单刷题-编程基础 0 到 1【二】

博客推行版本更新,成果积累制度,已经写过的博客还会再次更新,不断地琢磨,高质量高数量都是要追求的,工匠精神是学习必不可少的精神。因此,大家有何建议欢迎在评论区踊跃发言,你们的支持是我最大的动力,你们敢投,我就敢肝 ......
笔试 实战 LeetCode 基础

LeetCode 148. 排序链表

``` class Solution { public: ListNode* sortList(ListNode* head) { if(!head||!head->next) return head; ListNode* fast=head,*slow=head; while(fast->next ......
LeetCode 148

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

#题目链接: [LeetCode 501. 二叉搜索树中的众数](https://leetcode.cn/problems/find-mode-in-binary-search-tree/description/) ##题意: **给你一个含重复值的二叉搜索树(BST)的根节点 root ,找出并返 ......
LeetCode 501

LeetCode 图

200. 岛屿数量 695. 岛屿的最大面积 精品题解 https://leetcode.cn/problems/number-of-islands/solution/dao-yu-lei-wen-ti-de-tong-yong-jie-fa-dfs-bian-li-/ 注意深度优先遍历,对一格陆地 ......
LeetCode

[Leetcode Weekly Contest]350

链接:[LeetCode](https://leetcode-cn.com/contest/weekly-contest-350/) ## [Leetcode]2739. 总行驶距离 卡车有两个油箱。给你两个整数,mainTank 表示主油箱中的燃料(以升为单位),additionalTank 表示 ......
Leetcode Contest Weekly 350

LeetCode 146. LRU缓存机制

``` class LRUCache { public: struct node { int key,val; node *l,*r; node(int a,int b) { l=r=NULL; key=a; val=b; } }*L,*R; unordered_map mp;//保存key和节点的 ......
缓存 LeetCode 机制 146 LRU

每日一题 力扣 445 https://leetcode.cn/problems/add-two-numbers-ii/

可以直接用栈去做就行,逆序想到栈的做法 然后算完一个就直接赋值给答案数组 我用的是常见 public ListNode addTwoNumbers(ListNode l1, ListNode l2) { int sizeA=0; int sizeB=0; ListNode start=l1; Lis ......

leetcode933使用队列

输入的时间是递增的 输出 的时[t-3000,t] queue <int>q; int ping(int t){ q.push(t); while(q.front<t-3000){ q,pop(); } return q.size(); } ......
队列 leetcode 933

convert string list to number list

``` #string with integers sepated by spaces string1="1 2 3 4 5 6 7 8" print("Actual String containing integers: ",string1) print("Type of string: ",ty ......
list convert string number to

LeetCode -- 767. 重构字符串

设字符串s长度为len s可以重构为相邻字符串不同时 有字符串中出现次数最多的字符 < (len + 1) >> 1 当满足上述条件时候,我们就能对其进行重构 重构法:先放置偶数位置,再放置奇数位置 c ++ class Solution { public: string reorganizeStr ......
字符串 字符 LeetCode 767

【LeetCode剑指offer#05】回文链表的两种解法+删除链表中间节点(链表的基本操作)

### 回文链表 给你一个单链表的头节点 head ,请你判断该链表是否为回文链表。如果是,返回 true ;否则,返回 false 。 示例 1: 输入:head = [1,2,2,1] 输出:true 示例 2: 输入:head = [1,2] 输出:false 提示: 链表中节点数目在范围[1 ......
回文 解法 基本操作 节点 LeetCode

【leetcode】【1474】【删除链表 M 个节点之后的 N 个节点】

# c++ ## 第一个方法 ```c++ #include #include #include #include // Definition for singly-linked list. struct ListNode { int val; ListNode* next; ListNode() ......
节点 leetcode 1474