矩阵leetcode 100 240

VSCode使用JavaScript刷LeetCode配置教程(亲试可以!)

账号秘密都对,但是缺登录不成功的问题 诀窍可能是: 在属性设置中把LeetCode版本改成cn。点击LeetCode配置,修改Endpoint配置项,改成leetcode-cn,再次尝试登陆即可。 大家可移步原博文:https://blog.csdn.net/qq_37263248/article/ ......
JavaScript LeetCode 教程 VSCode

leetcode1260

这是一道模拟题 刚开始准备纯模拟,而后在题解看到一维压缩,才发现其实是将矩阵按行展开后进行k次右移操作。 转换成一维后,难点就在转换坐标:行号 = idx / 列数;列号 = idx % 列数; ......
leetcode 1260

[LeetCode][279]perfect-squares

# Content Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is an integer that is the square of an ......
perfect-squares LeetCode perfect squares 279

leetcode236求最近公共祖先

递归 TreeNode* dfs(TreeNode* root,TreeNode* p,TreeNode* q){ if(!root)return root;//当发现这个节点已经是叶节点时,要告诉上层 if(root==p||root==q)return root;//当发现是p节点或者q时也要告 ......
祖先 leetcode 236

Leetcode1636——按照频率将数组升序排序

给你一个整数数组 nums ,请你将数组按照每个值的频率 升序 排序。如果有多个值的频率相同,请你按照数值本身将它们 降序 排序。 请你返回排序后的数组。 示例 1: 输入:nums = [1,1,2,2,2,3] 输出:[3,1,1,2,2,2] 解释:'3' 频率为 1,'1' 频率为 2,'2 ......
升序 数组 频率 Leetcode 1636

【LeetCode动态规划#16】矩阵的最小路径和、三角形的最小路径和

### 矩阵的最小路径和 给定一个包含非负整数的 `*m* x *n*` 网格 `grid` ,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。 **说明:**一个机器人每次只能向下或者向右移动一步。 **示例 1:** ``` 输入:grid = [[1,3,1],[1,5,1],[ ......
路径 矩阵 三角形 LeetCode 动态

[LeetCode][221]maximal-square

# Content Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example 1: Input: mat ......
maximal-square LeetCode maximal square 221

[LeetCode][198]house-robber

# Content You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint s ......
house-robber LeetCode robber house 198

【LeetCode动态规划#15】最长公共子序列II

### 最长公共子序列(二) #### 描述 给定两个字符串str1和str2,输出两个字符串的最长公共子序列。如果最长公共子序列为空,则返回"-1"。目前给出的数据,仅仅会存在一个最长的公共子序列 数据范围:0≤∣���1∣,∣���2∣≤20000≤∣*s**t**r*1∣,∣*s**t**r* ......
序列 LeetCode 动态 15

代码随想录第二天|977.有序数组的平方;209.长度最小的子数组;59.螺旋矩阵II,总结

今天的这三道题每道题对我来说都不简单,有序数组的平方和长度最小的子数组这两道题还能用暴力求解,螺旋矩阵看着简单却没有思路,磨了半小时还是决定直接看讲解 有序数组平方和用的双指针的思想,代码如下: 1 class Solution { 2 public: 3 vector<int> sortedSqu ......
数组 随想录 矩阵 螺旋 随想

20天 hot 100 速通计划-day16

### 堆 #### [295. 数据流的中位数](https://leetcode.cn/problems/find-median-from-data-stream/) **中位数**是有序整数列表中的中间值。如果列表的大小是偶数,则没有中间值,中位数是两个中间值的平均值。 - 例如 `arr = ......
hot 100 day 16

运用谱分解定理反求实对称矩阵

[toc] # 谱分解定理 设三阶**实对称矩阵** $A$,若矩阵 $A$ 的特征值为 $\lambda_1,\lambda_2,\lambda_3$,对应的特征向量分别为 $\alpha_1,\alpha_2,\alpha_3$ 且**两两正交**,则 $A = \lambda_1 \alpha ......
定理 矩阵

洛谷100题计划 (15/100)

# 洛谷100题计划 (15/100) ## [P1094 [NOIP2007 普及组] 纪念品分组 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)](https://www.luogu.com.cn/problem/P1094) **要使得分组最少,其实就是要让一个大的和一个小的 ......
100 15

【LeetCode1】统计参与通信的服务器

# 【题目】 - 这里有一幅服务器分布图,服务器的位置标识在 `m * n` 的整数矩阵网格 `grid` 中,1 表示单元格上有服务器,0 表示没有。 - 如果两台服务器位于同一行或者同一列,我们就认为它们之间可以进行通信。 - 请你统计并返回能够与至少一台其他服务器进行通信的服务器的数量。 # ......
LeetCode1 LeetCode 服务器

C语言经典100题之循环嵌套

1,有 1、2、3、4 四个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 思路分析:首先来分析这道题目,三位数,无非就是i,j,k的三种不同组合,互不相同翻译成C语言就是i!=j, i!=k,j!=k。无重复我们可以使用枚举法枚举所有的三位数,然后判断是否满足互不相同的条件即可,利用三 ......
语言 经典 100

[LeetCode][152]maximum-product-subarray

# Content Given an integer array nums, find a subarray that has the largest product, and return the product. The test cases are generated so that the ......

[LeetCode][139]word-break

# Content Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dict ......
word-break LeetCode break word 139

Leetcode——1957、删除字符使字符串变好

一个字符串如果没有 三个连续 相同字符,那么它就是一个 好字符串 。 给你一个字符串 s ,请你从 s 删除 最少 的字符,使它变成一个 好字符串 。 请你返回删除后的字符串。题目数据保证答案总是 唯一的 。 示例 1: 输入:s = "leeetcode" 输出:"leetcode" 解释: 从第 ......
字符 字符串 Leetcode 1957

[LeetCode][124]binary-tree-maximum-path-sum

# Content A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can onl ......

Leetcode 1. 两数之和(Two sum)

[题目链接🔗](https://leetcode.cn/problems/two-sum) 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素 ......
之和 Leetcode Two sum

[LeetCode] 1267. Count Servers that Communicate

You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that ......
Communicate LeetCode Servers Count 1267

Leetcode 1782. 统计点对的数目

这两天实训比较忙,之后补 TRANSLATE with x English Arabic Hebrew Polish Bulgarian Hindi Portuguese Catalan Hmong Daw Romanian Chinese Simplified Hungarian Russian ......
数目 Leetcode 1782

leetcode 12

![image](https://img2023.cnblogs.com/blog/3254178/202308/3254178-20230823182631200-1538353557.png) ### 算法介绍: - **哈希** - **贪心** - 实现代码如下 ```cpp class S ......
leetcode 12

20天 hot 100 速通计划-day15

### 栈 #### [394. 字符串解码](https://leetcode.cn/problems/decode-string/) 给定一个经过编码的字符串,返回它解码后的字符串。 编码规则为: `k[encoded_string]`,表示其中方括号内部的 `encoded_string` 正 ......
hot 100 day 15

跟随erik刷洛古100题

##11.P1094 [NOIP2007 普及组] 纪念品分组 题目给出每个纪念品的价格并且要分组,每组最多只能包括两件纪念品, 每组纪念品的价格之和不能超过一个给定的整数,求最少的分组数目。 可以给这一些价格排个序,然后判断最小的价格和最大的价格的价格之和是否在给定的整数 $w$ 以内,如果满足条 ......
erik 100

洛谷100题计划(10/100)

# 洛谷100题计划(10/100) ## [P1031 [NOIP2002 提高组] 均分纸牌 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)](https://www.luogu.com.cn/problem/P1031) **因为第$1$堆只能移动到第$2$堆,且第$N$堆只 ......
100 10

Leetcode605——种花问题

假设有一个很长的花坛,一部分地块种植了花,另一部分却没有。可是,花不能种植在相邻的地块上,它们会争夺水源,两者都会死去。 给你一个整数数组 flowerbed 表示花坛,由若干 0 和 1 组成,其中 0 表示没种植花,1 表示种植了花。另有一个数 n ,能否在不打破种植规则的情况下种入 n 朵花? ......
Leetcode 问题 605

Leetcode 202. 快乐数(Happy number)

[题目链接🔗](https://leetcode.cn/problems/happy-number) 编写一个算法来判断一个数 n 是不是快乐数。 「快乐数」 定义为: 对于一个正整数,每一次将该数替换为它每个位置上的数字的平方和。 然后重复这个过程直到这个数变为 1,也可能是 无限循环 但始终变 ......
Leetcode number Happy 202

[LeetCode][121]best-time-to-buy-and-sell-stock

# Content You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a s ......

[LeetCode][96]unique-binary-search-trees

# Content Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 t ......