矩阵leetcode 100 240

[LeetCode][64]minimum-path-sum

# Content Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along ......
minimum-path-sum LeetCode minimum path sum

LeetCode[10]RegularExpressionMatching

# Content Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: '.' Matches any single ch ......
RegularExpressionMatching LeetCode 10

LeetCode[32]LongestValidParentheses

# Content Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring. Examp ......
LongestValidParentheses LeetCode 32

LeetCode[42]TrappingRainWater

# Content Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raini ......
TrappingRainWater LeetCode 42

LeetCode[53]MaximumSubarray

# Content Given an integer array nums, find the subarray with the largest sum, and return its sum. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Ou ......
MaximumSubarray LeetCode 53

LeetCode[62]UniquePaths

# Content There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the ......
UniquePaths LeetCode 62

LeetCode[55]JumpGame

# Content You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your ......
LeetCode JumpGame 55

LeetCode[64]MinimumPathSum

# Content Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along ......
MinimumPathSum LeetCode 64

【LeetCode1270. 向公司CEO汇报工作的所有人】with recursive找到某节点所有的后代

# 题目地址 https://leetcode.cn/problems/all-people-report-to-the-given-manager/description/ # 代码 ``` WITH RECURSIVE cte_subordinates AS ( -- 基础情况: 找到直接下属 ......
节点 后代 recursive LeetCode 所有人

【剑指Offer】65、矩阵中的路径

# 【剑指Offer】65、矩阵中的路径 **题目描述:** 请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则之后不能再次进入这个格子。 例如 ......
矩阵 路径 Offer

代码随想录算法训练营第二天| 977.有序数组的平方 ,209.长度最小的子数组 ,59.螺旋矩阵II

977.有序数组的平方 题目 给你一个按 非递减顺序 排序的整数数组 nums,返回 每个数字的平方 组成的新数组,要求也按 非递减顺序 排序。 第一想法 隐隐约约有印象是用双指针法头尾一起向中间移动,因为这个数组的特点决定了平方数中间小两边大 思路&题解 class Solution { publ ......
数组 随想录 训练营 矩阵 螺旋

【leetcode】1.two sum

第一题给我干懵了...想达到这个要求把我脑壳都想痛了...Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity? 一开始想过用map,但是不能解决重复key的问题。 然而我用sort, ......
leetcode two sum

20天 hot 100 速通计划-day11

### 图论 #### [200. 岛屿数量](https://leetcode.cn/problems/number-of-islands/) 给你一个由 `'1'`(陆地)和 `'0'`(水)组成的的二维网格,请你计算网格中岛屿的数量。 岛屿总是被水包围,并且每座岛屿只能由水平方向和/或竖直方向 ......
hot 100 day 11

LeetCode 1581. 进店却未进行过交易的顾客

##题目 表:Visits ```sql + + + | Column Name | Type | + + + | visit_id | int | | customer_id | int | + + + visit_id 是该表中具有唯一值的列。 该表包含有关光临过购物中心的顾客的信息。 ``` ......
LeetCode 顾客 1581

Leetcode 19. 删除链表的倒数第N个结点(Remove nth node from end of list)

[题目链接](https://leetcode.cn/problems/remove-nth-node-from-end-of-list) 给你一个链表, 删除链表的倒数第n个结点, 并且返回链表的头结点. 示例 1: ``` 输入:head = [1,2,3,4,5], n = 2 输出:[1,2 ......
结点 Leetcode Remove node from

Leetcode148 排序链表

148. 排序链表 - 力扣(LeetCode) /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr ......
Leetcode 148

73.矩阵置零

[73.矩阵置零](https://leetcode.cn/problems/set-matrix-zeroes/solutions/6594/o1kong-jian-by-powcai/?envType=study-plan-v2&envId=top-100-liked) 思路: 思路一: 用 O ......
矩阵 73

20天 hot 100 速通计划-day10

### 二叉树 #### [114. 二叉树展开为链表](https://leetcode.cn/problems/flatten-binary-tree-to-linked-list/) 给你二叉树的根结点 `root` ,请你将它展开为一个单链表: - 展开后的单链表应该同样使用 `TreeNo ......
hot 100 day 10

240. 搜索二维矩阵 II

[240. 搜索二维矩阵 II](https://leetcode.cn/problems/search-a-2d-matrix-ii/solutions/2361487/240-sou-suo-er-wei-ju-zhen-iitan-xin-qin-7mtf/?envType=study-pla ......
矩阵 240 II

LeetCode -- 151. 反转字符串中的单词(手写一个trim函数)

本题我们采用 class Solution { public: string reverseWords(string s) { stack<string> stk; int n = s.size(), l = 0, r = n - 1; //trim函数 while(l < n && s[l] == ......
字符串 单词 函数 字符 LeetCode

第 358 场周赛 - 力扣(LeetCode)

# [第 358 场周赛 - 力扣(LeetCode)](https://leetcode.cn/contest/weekly-contest-358/) ## [2815. 数组中的最大数对和 - 力扣(LeetCode)](https://leetcode.cn/problems/max-pai ......
LeetCode 358

图论之存图-----邻接矩阵

![image](https://img2023.cnblogs.com/blog/3245044/202308/3245044-20230816100654756-1565941597.png) ###跟着思路敲了一遍,感觉清晰多了,但是还得多复习。就是利用了深度搜索,很奇妙。 点击查看代码 `` ......
矩阵

【leetcode】404 左叶子之和

https://leetcode.cn/problems/sum-of-left-leaves/description/ 【分析】 该题要求左叶子之和。 如果我们对当前节点进行叶子节点的判断,那么我们是不知道当前节点是左叶子还是右叶子的。 所以我们应该在叶子结点的上层(父节点)进行判断。 【代码】 ......
之和 leetcode 叶子 404

[LeetCode] 2682. Find the Losers of the Circular Game

There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, movin ......
the LeetCode Circular Losers 2682

LeetCode -- 19. 删除链表的倒数第 N 个结点

一般的删除问题,可以直接删除(找符合条件的,找到了直接删掉),延迟删除(打标记,找完了再删除),栈,双指针 在链表中删除一个节点,要找到其前面一个节点cur, 然后 cur -> next = cur -> next -> next即可 方法一:直接删除 我们先算出链表长度len,要删除倒第n个节点 ......
结点 LeetCode 19

矩阵最值

题目描述 我们有一个N 行 M列的矩阵,现在小Q有 K 个问题,每次询问一个以 (X1,Y1)为左上角, (X2,Y2)为右下角的子矩阵的最大值。 输入格式 第一行三个整数 N,M,K 。 接下来 N 行,每行有 M个整数,设Ai,j 为矩阵 i 行j 列的数字。 接下来 k 行,每行 4 个整数 ......
矩阵

【LeetCode 571. 给定数字的频率查询中位数】WITH RECURSIVE实现Tally的逆操作

[TOC] # 题目地址 https://leetcode.cn/problems/find-median-given-frequency-of-numbers/description/ # 代码 ``` WITH RECURSIVE RecCTE AS ( SELECT num, frequenc ......
中位数 RECURSIVE 频率 LeetCode 数字

【leetcode】【401】二进制手表

https://leetcode.cn/problems/binary-watch/description/ 分析 这是典型的循环DFS问题。 循环DFS一般应用在: 1. 输出字符的按位全排列。(比如一共4个数字,输出3个数字的全部组合) 2. 输出字符的全排列。(结合visited数组) 3. ......
二进制 手表 leetcode 401

CUDA之矩阵转置(全局内存、共享内存)

# 使用全局内存 [完整代码链接](https://github.com/brucefan1983/CUDA-Programming/blob/master/src/07-global-memory/matrix.cu) ## A合并访问、B非合并访问 ```c++ #ifdef USE_DP ty ......
内存 矩阵 全局 CUDA

20天 hot 100 速通计划-day09

### 二叉树 #### [102. 二叉树的层序遍历](https://leetcode.cn/problems/binary-tree-level-order-traversal/) 给你二叉树的根节点 `root` ,返回其节点值的 **层序遍历** 。 (即逐层地,从左到右访问所有节点)。 ......
hot 100 day 09