leetcode negative numbers matrix

[LeetCode] 1090. Largest Values From Labels

There is a set of n items. You are given two integer arrays values and labels where the value and the label of the ith element are values[i] and label ......
LeetCode Largest Labels Values 1090

leetcode2215哈希列表的应用

哈希列表存储的是不重复的元素,使用两个哈希列表存储这两个数组。再遍历其中一个哈希列表,查看是否存在另一个哈希列表中 set.insert() set1.count(元素) for(int num:nums1){ set1.insert(num); } for(int num:set1){ if(!s ......
leetcode 2215

LeetCode 95. 不同的二叉搜索树 II

``` class Solution { public: vector dfs(int l,int r)//返回以n为根节点的所有可能子树 { vector res; if(l>r) return {NULL}; for(int k=l;k left=dfs(l,k-1); vector right ......
LeetCode 95 II

LeetCode 103. 二叉树的锯齿形层次遍历

``` class Solution { public: vector> res; void bfs(TreeNode* root) { queue q; q.push(root); int cnt=0; while(!q.empty()) { vector level; int len=q.siz ......
锯齿 LeetCode 层次 103

LeetCode 周赛 346(2023/05/21)仅 68 人 AK 的最短路问题

> **本文已收录到 [AndroidFamily](https://github.com/pengxurui/AndroidFamily),技术和职场问题,请关注公众号 [彭旭锐] 提问。** - [LeetCode 单周赛第 345 场 · 体验一题多解的算法之美](https://mp.wei ......
LeetCode 问题 2023 346 05

关于Excel表格中对多个General或者Number数值格式的单元转换为Text文本时-值包含E+的方法处理

对于单元格的值为Number数字时,我们可以直接选中,单元格,或者某个范围,可以直接将上面的格式处选择为Text 这样就完成了一次格式转换,如下默认是General普通格式,我们直接就将其转换成Text文本格式 不过只有当我们将鼠标双击一下单元格式,才会看到左上角看到熟悉的Text绿色直接三角形标识 ......
数值 表格 单元 文本 多个

c语言刷leetcode——二分搜索

https://leetcode.cn/problems/path-with-minimum-effort/solutions/1345046/er-fen-by-dvuszkq61y-6vr1/ ![image](https://img2023.cnblogs.com/blog/1569451/2 ......
leetcode 语言

leetcode724

使用数学方法: 假设左边的所有数加起来的和是sum,total为数组所有元素加起来的和,当i满足中心下标的条件时,即: sum=total-sum-nums[i]; 2*sum+nums[i]=total; 当中心下标是首位时,即左边sum为0;当中心下标是尾位时,右边total-sum-nums[ ......
leetcode 724

js number format All In One

# js number format All In One > 金融数据表示法 ## 千分位符号 ```js // 1,000,000 ``` ## demos --> ## (🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblog ......
format number All One js

leetcode1493

递归: 1.记pre[i]为以i位置结尾的连续1长度。 pre[i]=0;ai=0 pre[i]=pre[i-1]+1;ai=1 记suf[i]为以位置i开头的连续1长度; suf[i]=0;ai=0 suf[i]=suf[i+1]+1;ai=1 计算删掉i位置的连续1的长度为pre[i-1]+su ......
leetcode 1493

CF446C. DZY Loves Fibonacci Numbers

好牛的题,写一下。 题意:维护一个序列 $a$,长度为 $n$,有 $m$ 次操作: - `1 l r`:对于 $i\in[l,r]$,$a_i\leftarrow a_i+f_{i-l+1}$。 - `2 l r`:求 $\displaystyle\left(\sum_{i=l}^ra_i\rig ......
Fibonacci Numbers Loves 446 DZY

Number Reduction

# [Number Reduction](https://codeforces.com/contest/1765/problem/N) ## 题意 删除k位数,让原本的数变得最小(不含前导零) ## 思路 看官方题解学会的。记录每种数字出现的位置,原本有n位,那结果就有n-k位,一位位枚举,然后尽量 ......
Reduction Number

leetcode 23. 合并 K 个升序链表

题目链接:https://leetcode.cn/problems/merge-k-sorted-lists/ 第一种写法,不断将未排序的链表插入到一个已经排序的链表中。 这样写的问题在于,当未排序的链表逐渐变的很大时,每插入一个新链表,都会来一次O(kn),总时间复杂度为O(k²n) 我们可以通过 ......
升序 leetcode 23

LeetCode 106. 从中序与后序遍历序列构造二叉树

###题目链接:[LeetCode 106. 从中序与后序遍历序列构造二叉树](https://leetcode.cn/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) ###题意: 给定两个整数数组 inor ......
序列 从中 LeetCode 106

LeetCode 105. 从前序与中序遍历序列构造二叉树

###题目链接:[LeetCode 105. 从前序与中序遍历序列构造二叉树](https://leetcode.cn/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) ###题意: 给定两个整数数组 preor ......
序列 LeetCode 105

LeetCode 113. 路径总和 II

###题目链接:[LeetCode 113. 路径总和 II](https://leetcode.cn/problems/path-sum-ii/) ###题意: 给你二叉树的根节点 root 和一个整数目标和 targetSum ,找出所有 从根节点到叶子节点 路径总和等于给定目标和的路径。 ## ......
总和 路径 LeetCode 113 II

LeetCode 112. 路径总和

###题目链接:[LeetCode 112. 路径总和](https://leetcode.cn/problems/path-sum/) ###题意: 给你二叉树的根节点 root 和一个表示目标和的整数 targetSum 。判断该树中是否存在 根节点到叶子节点 的路径,这条路径上所有节点值相加等 ......
总和 路径 LeetCode 112

leetcode简单题

1. 两数之和①difference[]=target - num[]中的数 单循环②在num[]中寻找与difference[]相等但两者下标不等的数 双重循环 找到第一个后循环停止 9.判断数字是否为回文数①将数字转换为字符串②使用双指针,一个指向前端,一个指向后端③循环:当前端指针小于后端指针 ......
leetcode

leetcode 1321 餐館營業額變化增長

leetcode 1321 餐館營業額變化增長 select distinct c2.visited_on, (select sum(amount) from Customer c1 where c1.visited_on <= c2.visited_on and c1.visited_on >= ......
leetcode 1321

二刷Leetcode-Days04

数组: /** * 27. 移除元素 * @param nums * @param val * @return 很多考察数组、链表、字符串等操作的面试题,都使用双指针法。 */ public int removeElement(int[] nums, int val) { int left = 0; ......
Leetcode-Days Leetcode Days 04

[LeetCode] 2446. Determine if Two Events Have Conflict

You are given two arrays of strings that represent two inclusive events that happened on the same day, event1 and event2, where: event1 = [startTime1, ......
Determine LeetCode Conflict Events 2446

LeetCode 5. 最长回文子串

class Solution { public: string longestPalindrome(string s) { string res; int n=s.size(); for(int i=0;i<n;i++) { //长度是奇数 int l=i-1,r=i+1; while(l>=0&& ......
回文 LeetCode

LeetCode 257. 二叉树的所有路径

###题目链接:LeetCode 257. 二叉树的所有路径 ###题意: 给你一个二叉树的根节点 root ,按 任意顺序 ,返回所有从根节点到叶子节点的路径。 ###解题思路: ####递归法 采用递归法,就是一个dfs的过程,在遍历过程中,记录上路径即可。 ####完整代码如下: var re ......
路径 LeetCode 257

LeetCode 110. 平衡二叉树

###题目链接:LeetCode 110. 平衡二叉树 ###题意: 给定一个二叉树,判断它是否是高度平衡的二叉树。 ###解题思路: ####1.递归法: 对于递归法,既然是求树的高度,则应该使用后序遍历的方式, 对于每个节点,求左右子树的高度,比较左右子树的高度差是否小于1,如果不满足,返回fa ......
LeetCode 110

2023-05-15 leetcode周赛题

找出转圈游戏输家 my solution 100% pass class Solution: def circularGameLosers(self, n: int, k: int) -> List[int]: seen = set() now_num = 1 step = 1 seen.add(1 ......
leetcode 2023 05 15

leetcode bash题--统计词频

写一个 bash 脚本以统计一个文本文件 words.txt 中每个单词出现的频率。 为了简单起见,你可以假设: words.txt只包括小写字母和 ' ' 。每个单词只由小写字母组成。单词间由一个或多个空格字符分隔。示例: 假设 words.txt 内容如下: the day is sunny t ......
词频 leetcode bash

LeetCode刷题记录|LeetCode热题100|136.只出现一次的数字(easy)

题目描述:给你一个 非空 整数数组 nums ,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。你必须设计并实现线性时间复杂度的算法来解决此问题,且该算法只使用常量额外空间。 时间复杂度:O(n) ,其中 n 是数组长度。只需要对数组遍历一次。 空间复杂度:O(1) ......
LeetCode 数字 easy 100 136

leetcode 626 換座位

leetcode 626 換座位 SELECT (CASE WHEN MOD(id, 2) != 0 AND counts != id THEN id + 1 WHEN MOD(id, 2) != 0 AND counts = id THEN id ELSE id - 1 END) AS id, s ......
座位 leetcode 626

leetcode 619 只出現一次的最大數字

leetcode 619 只出現一次的最大數字 select max(num) as num from ( select num as num from MyNumbers group by num having count(num) = 1 ) as mn select if(count(num) ......
leetcode 619

leetcode 1679

1.排序双指针 先排序 sort(nums.begin(),nums.end()); 在双指针查找 while(left<right){ if(nums[left]+nums[right]<k){ left++; }else if(nums[left]+nums[right]>k){ right-- ......
leetcode 1679