矩阵leetcode 100 240

邻接表和邻接矩阵:图的两种存储方式

引言 图是一种非常重要的数据结构,它可以用来表示很多复杂的现实问题,如网络拓扑、社交关系、地图导航等。为了有效地处理图相关的算法,我们需要选择合适的存储方式来表示图中的顶点和边。本文将介绍图的两种常用存储方式:邻接表和邻接矩阵,并比较它们的优缺点。 邻接矩阵 邻接矩阵是使用二维数组存储图的所有顶点间 ......
矩阵 方式

8-102-(LeetCode- 207&210) 课程表II

1. 题目 读题 210. 课程表 II 考查点 2. 解法 思路 这道题的解答思路是使用拓扑排序来判断有向图是否有环,如果有环,说明无法完成所有课程,如果没有环,输出拓扑排序的结果。拓扑排序的基本思想是从有向图中选择一个没有前驱(即入度为0)的顶点并输出,然后从图中删除该顶点和所有以它为起点的有向 ......
课程表 LeetCode 课程 102 207

LeetCode 287. 寻找重复数

``` class Solution { public: int findDuplicate(vector& nums) { if(nums.size()<2) return nums[0]; int n=nums.size(); int fast=0,slow=0; do { slow=nums[ ......
LeetCode 287

LeetCode 热题 100 之 160. 相交链表

# 题目描述 给你两个单链表的头节点 headA 和 headB ,请你找出并返回两个单链表相交的起始节点。如果两个链表不存在相交节点,返回 null 。 图示两个链表在节点 c1 开始相交: ![image](https://img2023.cnblogs.com/blog/2204134/202 ......
LeetCode 100 160

LeetCode 热题 100 之 15. 三数之和

# 题目描述 给你一个整数数组 nums ,判断是否存在三元组 [nums[i], nums[j], nums[k]] 满足 i != j、i != k 且 j != k ,同时还满足 nums[i] + nums[j] + nums[k] == 0 。请 你返回所有和为 0 且不重复的三元组。 注 ......
之和 LeetCode 100 15

LeetCode 热题 100 之 11. 盛最多水的容器

# 题目描述 给定一个长度为 n 的整数数组 height 。有 n 条垂线,第 i 条线的两个端点是 (i, 0) 和 (i, height[i]) 。 找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 返回容器可以储存的最大水量。 说明:你不能倾斜容器。 示例 1: ![im ......
容器 LeetCode 100 11

LeetCode 793. Preimage Size of Factorial Zeroes Function 二分

Let `f(x)` be the number of zeroes at the end of x!. Recall that $x! = 1 * 2 * 3 * ... * x$ and by convention, 0! = 1. For example,` f(3) = 0` because ......
Factorial LeetCode Function Preimage Zeroes

LeetCode 周赛上分之旅 #33 摩尔投票派上用场

> ⭐️ **本文已收录到 [AndroidFamily](https://github.com/pengxurui/AndroidFamily),技术和职场问题,请关注公众号 [彭旭锐] 和 [BaguTree Pro] 知识星球提问。** > > 学习数据结构与算法的关键在于掌握问题背后的算法思 ......
用场 LeetCode 之旅 33

第100篇,写给最爱的人,一周年快乐

这篇没有渲染,没有图片,就是我想对你重新表白。正好这是我第100篇文章,用这种形式也算是我的一份小礼物吧。 一年前,你用一句“你生日这天把我送给你应该是你最想要的礼物了吧”,“空着手”就答应了我的追求,你也说“从一个人到两个人,从卸下防备到开怀大笑”。再到这一年里发生的所有事情,有让你开心,有让你难 ......
最爱 100

leetcode day4 24 19 面试题02.07 142

[toc] #24. 两两交换链表中的节点 ![](https://img2023.cnblogs.com/blog/3239608/202307/3239608-20230715224335895-687431293.png) ![](https://img2023.cnblogs.com/blo ......
leetcode 02.07 day4 day 142

LeetCode 658. Find K Closest Elements 二分+双指针

Given a sorted integer array `arr`, two integers `k` and `x`, return the `k` closest integers to `x` in the array. The result should also be sorted in ......
指针 LeetCode Elements Closest Find

LeetCode -- 870. 优势洗牌

贪心:这种最大化类似于田忌赛马。 每次取出nums1中最小的,和nums2进行比较,如果打得过,就打;打不过就用当前最小的和nums2中最大的换掉 c ++ class Solution { public: vector<int> advantageCount(vector<int>& nums1, ......
LeetCode 优势 870

2023/7/15(一个循环矩阵的行列式的计算)

![](https://img2023.cnblogs.com/blog/2702872/202307/2702872-20230715165746040-2007224709.png) ![](https://img2023.cnblogs.com/blog/2702872/202307/2702 ......
行列式 矩阵 行列 2023 15

矩阵相关模板

## 矩阵快速幂 ``` #include #include #include #include #include using namespace std; const int N = 150; const int mod = 1e9 + 7; typedef long long lld; inli ......
矩阵 模板

leetcode刷题记录Java

``` 难度等级:简单 给你两个字符串 word1 和 word2 。请你从 word1 开始,通过交替添加字母来合并字符串。 如果一个字符串比另一个字符串长,就将多出来的字母追加到合并后字符串的末尾。 返回 合并后的字符串 。 class Solution { public String merg ......
leetcode Java

leetcode刷题记录(C语言)

``` 给你两个字符串 word1 和 word2 。请你从 word1 开始,通过交替添加字母来合并字符串。 如果一个字符串比另一个字符串长,就将多出来的字母追加到合并后字符串的末尾。 返回 合并后的字符串 。 输入:word1 = "abc", word2 = "pqr" 输出:"apbqcr" ......
leetcode 语言

矩阵LED分时点亮

原理:分时驱动LED_PIN1,LED_PIN2,LED_PIN3为低电平。再来同时置位LED_SEG1,LED_SEG2,LED_SEG3,LED_SEG4,达到分时点亮矩阵LED的效果, 缺点是LED比正常点亮暗一些,其他无差异。 上程序 void swled(void) { static ui ......
矩阵 LED

Leetcode283. 移动零

``` class Solution { public: void moveZeroes(vector& nums) { if(nums.empty()) return; int n=nums.size(); int idx=n-1; while(idx>=0&&nums[idx]==0) idx- ......
Leetcode 283

Leetcode240.搜索二维矩阵II

``` class Solution { public: bool searchMatrix(vector>& matrix, int target) { if(matrix.empty()||matrix[0].empty()) return false; int n=matrix.size(), ......
矩阵 Leetcode 240

[LeetCode] 1218. Longest Arithmetic Subsequence of Given Difference

Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that th ......

矩阵颜色

# problem 一个 $n\times m$ 的矩阵,第 $i$ 行第 $j$ 列元素有一个颜色 $c_{i,j}$,求所有子矩阵的颜色种类数的平均值。 ......
矩阵 颜色

比Wi-Fi快100倍!Li-Fi无线传输标准802.11bb正式发布:带宽高达224GB/s

大家对Wi-Fi可以说耳熟能详,最新标准已经演进到802.11be,即Wi-Fi 7,理论速率可达30Gbps。 现在,更强的来了。 IEEE今日正式签署802.11bb无线传输标准,即Li-Fi,基于光波的无线传输。 Li-Fi支持者认为,光比射频更可靠,由此也使得Li-Fi比Wi-Fi和5G都要 ......
高达 带宽 无线 标准 802.11

LeetCode 354. Russian Doll Envelopes 排序+LIS

You are given a 2D array of integers `envelopes` where `envelopes[i] = [wi, hi]` represents the width and the height of an envelope. One envelope can ......
Envelopes LeetCode Russian Doll 354

LeetCode 519. Random Flip Matrix 哈希Map

There is an `m x n` binary grid matrix with all the values set 0 initially. Design an algorithm to randomly pick an index `(i, j)` where `matrix[i][j] ......
LeetCode Random Matrix Flip 519

LeetCode 239. 滑动窗口最大值

``` class Solution { public: vector maxSlidingWindow(vector& nums, int k) { deque q; vector res; for(int i=0;i=k) q.pop_front(); //插入新元素 while(q.size( ......
最大值 LeetCode 239

C语言算法100例实战题

适合人群:1:从来没接触过编程的小白,可以从零基础开始学习2:接触过C语言基础不扎实,可以通过学习提高自己课程介绍:1:本课全套共计100节。2:定期更新课程内容及技术体系。3:享受老师一对一技术指导与服务。4:报名后联系老师QQ:726920220,领取全套学习资料。5:购买本课程,各位同学们可享 ......
算法 实战 语言 100

LeetCode 剑指 Offer 13. 机器人的运动范围

#题目链接:[LeetCode 剑指 Offer 13. 机器人的运动范围](https://leetcode.cn/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/) ##题意: **地上有一个m行n列的方格,从坐标 [0,0] 到坐标 [m-1,n-1] ......
机器人 LeetCode 范围 机器 Offer

leetcode day2 977 209 59

[toc] #977 ##暴力法 直接数组中每个元素平方后用sort进行排序 ##双指针法 数组是有序的,平方后最大的元素存在于nums的两端,所以就定义两个指向两端的指针, 然后比较两端绝对值的大小,大的加入新定义的ans数组,并且指针向内移动 ``` vector ans (nums.size( ......
leetcode day2 day 977 209

2023 Tsinghua-HKUST I <状压dp + 矩阵快速幂优化>

### 题目 [ I. Chinese chess]() ![image](https://img2023.cnblogs.com/blog/3165412/202307/3165412-20230713161936771-157024587.png) ### 代码 Code ``` // #inc ......
矩阵 Tsinghua-HKUST Tsinghua HKUST 2023

矩阵乘法

# 矩阵乘法入门 ## 矩阵 类似一个二维数组吧。 ## 矩阵的运算 ### 矩阵的加法 $$ C_{i,j} = A_{i,j} + B_{i,j} $$ 我不知道有什么用。 ### 矩阵的减法 $$ C_{i,j} = A_{i,j} - B_{i,j} $$ 我也不知道有什么用。 ### 矩阵 ......
乘法 矩阵