substitutions leetcode check after
leetcode2095链表的删除操作
遇见中间节点就删除这个节点 可以用快慢指针 ListNode*fast=head; ListNode*slow=head; LiseNose*pre; whie(fast&&fast->next){//在这里中间节点是向下取整,因此可能会跳过一个节点,所以两个判断条件 fast=fast->next ......
LeetCode 215. 数组中的第K个最大元素
# 小根堆 ``` class Solution { public: int findKthLargest(vector& nums, int k) { priority_queue,greater> q; for(auto x:nums) { if(q.size()& nums, int k) { ......
LeetCode/使数组中的所有元素都等于零(差分数组)
给你一个下标从 0 开始的整数数组 nums 和一个正整数 k 。 你可以对数组执行下述操作 任意次 : 从数组中选出长度为 k 的任一子数组,并将子数组中每个元素都减去 1 如果你可以使数组中的所有元素都等于 0 ,返回 true ,否则,返回 false。 ###1. 差分数组 从左往右贪心进行 ......
LeetCode/知道秘密的人数
在第 1 天,有一个人发现了一个秘密。 给你一个整数 delay ,表示每个人会在发现秘密后的 delay 天之后,每天 给一个新的人分享秘密。 同时给你一个整数 forget ,表示每个人在发现秘密 forget 天之后会 忘记 这个秘密。一个人不能在忘记秘密那一天及之后的日子里分享秘密。 ### ......
5. Q_ 伪类选择器__checked_将作用与_input_类型为_radio_或者_check
5. Q: 伪类选择器`:checked`将作用与`input`类型为`radio`或者`checkbox`,不会作用于`option`。 A: 不对。 伪类选择器`checked`的定义很明显: > The :checked CSS pseudo-class selector represents ......
LeetCode -- 353场周赛
找规律的小题目 c ++ class Solution { public: int theMaximumAchievableX(int num, int t) { return num + t * 2; } }; 思路,动态规划。 f[i]表示,所有从0 - i - 1中跳到点 i 的方式的执行操作 ......
LeetCode 207. 课程表
``` class Solution { public: bool canFinish(int n, vector>& pre) { if(pre.empty()||pre[0].empty()) return true; vector> g(n,vector(n,false)); for(auto ......
LeetCode -- 108场双周赛
利用差分和动态规划进行求解。首先求出差分数组d[i],f[i]表示从0-i - 1中选,且包含d[i]所有交替子数组的最大长度。 条件中有s1 = s0 + 1 所以如果d[i] == 1 将 f[i]初始化为1 d[i - 1] == 1 && d[i] == -1 或者 d[i - 1] == ......
LeetCode/黑格子的数目
一个块定义为网格图中 2 x 2 的一个子矩阵 请你返回一个下标从 0 开始长度为 5 的整数数组 arr ,arr[i] 表示恰好包含 i 个 黑色格子的块的数目 ###1. 搜索黑格子周围格子 ``` class Solution { public: int dir[4][2] = {{-1,- ......
LeetCode —— 买卖股票的最佳时机专题
121. 买卖股票的最佳时机 minPrice 维护到当天为止的最低价格 maxProfit 维护到当天我为止的最大利润 例如: [2,5,1,3], 第二天: minPrice=2 maxProfit=3; 第四天:minPrice=1 maxProfit=max(3, 3-1=2)=3; cla ......
LeetCode —— 贪心
55. 跳跃游戏 如果当前数字为3,代表在这一格可以跳1或2或3格 维护一个全局最远可到达的下标 maxReach 遍历 nums 数组,如果 maxReach 小于当前下标 i ,说明现在这里就不可以到达,更别说终点了,return false 接下来就是现在这个下标可以到达的情况 现在这个下标的 ......
LeetCode -- 792. 匹配子序列的单词数
方法1:利用桶的思想同时匹配所有words中的子串 (走路写法) 把所有首字母相同的子串放入到一个桶中,然后遍历s,对于首字母为s[i]的单词,若其大小为1则res ++, 否则删掉s[i],并根据s[i + 1]放入新的桶中。 c ++ class Solution { public: int n ......
LeetCode 206. 反转链表
``` /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x ......
LeetCode -- 764. 最大加号标志
利用动态规划的思想,把每个格子上下左右连续的1的个数算出来,再从头到尾遍历一遍即可获得答案。 c ++ class Solution { public: int orderOfLargestPlusSign(int n, vector<vector<int>>& mines) { vector<ve ......
做题日记:1881. 插入后的最大值(leetcode)
题目: >给你一个非常大的整数 n 和一个整数数字 x ,大整数 n 用一个字符串表示。n 中每一位数字和数字 x 都处于闭区间 [1, 9] 中,且 n 可能表示一个 负数 。 >你打算通过在 n 的十进制表示的任意位置插入 x 来 最大化 n 的 数值 。但 不能 在负号的左边插入 ......
c语言刷leetcode——图
[TOC] # 0.图和树的关系 1. 树是特殊的图,且是有向图 2. 树中没有环,而图中可能有 # 1.图的存储方式 - 图由点集和边集组成 - 图分为有向图和无向图,无向图可以理解为双向有向图 ## 1.1 邻接表 和 邻接矩阵 - 常见的图存储方式由邻接表(点集为核心)和邻接矩阵(边集为核心) ......
Check&Review的区别
在我们日常的GMP记录中,经常看见复核人或者审核人这样的字眼,那么二者到底有什么区别呢?日常我们又该如何做复核?如何做审核呢? “复核”,强调的是现场的第二人确认;而“审核”,强调的是非现场(或者事后)的再次审查。 我们再来看下二个英文单词Check&Review的区别,Check means lo ......
leetcode-682.棒球比赛
```go package main import ( "strconv" ) /* * @lc app=leetcode.cn id=682 lang=golang * * [682] 棒球比赛 */ // @lc code=start func sum(numbers []int) int { ......
leetcode 1466 重新规划路线 题解
### 解题思路 执行用时:140 ms, 在所有 Go 提交中击败了100.00%的用户 内存消耗:16.8 MB, 在所有 Go 提交中击败了82.00%的用户 将连接图转化成有向图,用二维slice存放。 此处将连接的起点设置为`from`也就是graph的外层下标,将连接的目标设为`targ ......
LeetCode 200. 岛屿数量
``` class Solution { public: bool st[310][310]; int dx[4]={0,0,-1,1},dy[4]={-1,1,0,0}; int m,n; int numIslands(vector>& g) { int res=0; n=g.size(),m=g ......
LeetCode 169. 多数元素
``` class Solution { public: int majorityElement(vector& nums) { int cnt=1; int res=nums[0]; for(int i=1;i<nums.size();i++) { if(nums[i]==res) cnt++; ......
LRU 力扣 146 https://leetcode.cn/problems/lru-cache/
一道经典题目,用双向链表去做能够满足O1的复杂度 核心代码如下 class LRUCache { MyLinkedList myLinkedList; int size; int capacity; HashMap<Integer, MyNode> map; public LRUCache(int ......
[LeetCode] 2024. Maximize the Confusion of an Exam
A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing ......
LeetCode
[剑指offer 05.替换空格](https://leetcode.cn/problems/ti-huan-kong-ge-lcof/) ```cpp class Solution { public: string replaceSpace(string s) { string out; for( ......
Python中os.system()、subprocess.run()、call()、check_output()的用法
### 1.os.system() os.system() 是对 C 语言中 system() 系统函数的封装,允许执行一条命令,并返回退出码(exit code),命令输出的内容会直接打印到屏幕上,无法直接获取。 示例: ```python # test.py import os os.syste ......
leetcode649队列操作Dota2
基本操作 入队: queue.push() queue.push_back()//两者效果相同 出队: queue.pop(); queue.pop_back();//都从尾部操作 考虑两个因素:1.每个参议员的决定都由之后的参议员决定 2.决定禁用之后都不能在投票 queue<int>radian ......
[LeetCode] 2178. Maximum Split of Positive Even Integers
You are given an integer finalSum. Split it into a sum of a maximum number of unique positive even integers. For example, given finalSum = 12, the fol ......
[LeetCode] 2600. K Items With the Maximum Sum
There is a bag that consists of items, each item has a number 1, 0, or -1 written on it. You are given four non-negative integers numOnes, numZeros, n ......
Leetcode: Algorithm
1. Boyer-Moore Voting Algorithm identify the majority element (frequency > n/2) class Solution { public int majorityElement(int[] nums) { int count = ......
leetcode-1652-easy
Defuse the Bomb ``` You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array code of length of n ......