leetcode 454 ii

算法训练day11 栈与队列 02 LeetCode20

算法训练day11 栈与队列 02 LeetCode20.1047.150 20.有效的括号: 题目: 20. 有效的括号 - 力扣(LeetCode) 题解: 代码随想录 (programmercarl.com) class Solution { public: bool isValid(stri ......
队列 算法 LeetCode day 11

Leetcode刷题70.爬楼梯

题目:假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 示例 1: 输入:n = 2 输出:2 解释:有两种方法可以爬到楼顶。 1. 1 阶 + 1 阶 2. 2 阶 示例 2: 输入:n = 3 输出:3 解释:有三种方法可以爬 ......
楼梯 Leetcode 70

leetcode71. 简化路径

class Solution: def simplifyPath(self, path: str) -> str: li=path.split("/") res=[] for i in li: if i=='..' and res: res.pop() if i!='.' and i!='..' a ......
路径 leetcode 71

算法训练day10 LeetCode 232

算法训练day10: LeetCode 232.225. 232.用栈实现队列 题目 232. 用栈实现队列 - 力扣(LeetCode) 题解 代码随想录 (programmercarl.com) class MyQueue { public: stack<int> stIn; stack<int ......
算法 LeetCode day 232 10

leetcode 加油站——一次遍历

class Solution: def canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int: n=len(gas) max_gas=0 rest=0 records=[] start=0 for i in range(n) ......
加油站 leetcode

【LeetCode】删除数对后的最小数组长度

题目 给你一个下标从 0 开始的 非递减 整数数组 nums 。 你可以执行以下操作任意次: 选择 两个 下标 i 和 j ,满足 i < j 且 nums[i] < nums[j] 。 将 nums 中下标在 i 和 j 处的元素删除。剩余元素按照原来的顺序组成新的数组,下标也重新从 0 开始编号 ......
数组 长度 LeetCode

leetcode 二叉树的最小深度

给定一个二叉树,找出其最小深度。 最小深度是从根节点到最近叶子节点的最短路径上的节点数量。 说明:叶子节点是指没有子节点的节点。 示例 1: 输入:root = [3,9,20,null,null,15,7] 输出:2 示例 2: 输入:root = [2,null,3,null,4,null,5, ......
深度 leetcode

leetcode 平衡二叉树

给定一个二叉树,判断它是否是高度平衡的二叉树。 本题中,一棵高度平衡二叉树定义为: 一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1 。 示例 1: 输入:root = [3,9,20,null,null,15,7] 输出:true 示例 2: 输入:root = [1,2,2,3,3, ......
leetcode

代码随想录算法训练营-回溯算法-2|55. 跳跃游戏、45. 跳跃游戏 II、1005. K 次取反后最大化的数组和

55. 跳跃游戏 1. 跳跃的覆盖范围。这个问题就转化为跳跃覆盖范围究竟可不可以覆盖到终点! 2. 贪心算法局部最优解:每次取最大跳跃步数(取最大覆盖范围),整体最优解:最后得到整体最大覆盖范围,看是否能到终点。 时间复杂度: O(n) 空间复杂度: O(1) 1 class Solution: 2 ......
算法 随想录 训练营 数组 随想

[LeetCode] 1222. Queens That Can Attack the King

On a 0-indexed 8 x 8 chessboard, there can be multiple black queens ad one white king. You are given a 2D integer array queens where queens[i] = [xQue ......
LeetCode Attack Queens 1222 King

[LeetCode] 2596. Check Knight Tour Configuration

There is a knight on an n x n chessboard. In a valid configuration, the knight starts at the top-left cell of the board and visits every cell on the b ......
Configuration LeetCode Knight Check 2596

LeetCode-Java题解 209. Minimum Size Subarray Sum

题目地址:209. Minimum Size Subarray Sum 解题思路: 看到这道题,心里本身是有双指针这个概念的,但是不知道怎么用,脑子里第一反应就是暴力解法,双for一把梭,然后时间就超时了...看了题解才知道滑动窗口这个解法,不禁直呼妙啊!感觉和双指针非常类似,其核心点在于避免了暴力 ......

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

Day2-数组2023.9.15 Leetcode977 有序数组的平方 给你一个按 非递减顺序 排序的整数数组 nums,返回 每个数字的平方 组成的新数组,要求也按 非递减顺序 排序。 初解 我还是不能想到暴力解法之外的,对某个问题的最优复杂度也没有概念。就算提示我是用指针,我也想不到思路。 现 ......
数组 随想录 训练营 矩阵 螺旋

leetcode1466

分析: 它是有n个节点,n-1条边 所以两个节点连接的边只有一条,那么要么是可以从这条边的起点开始能够到达0,要么是不能,不会有回路的情况 对于数据结构使用哈希表值为vector容器 int bfs(vector<vector<int>>& connections){ unordered_map<i ......
leetcode 1466

删除有序数组中的重复项 II

题目 删除有序数组中的重复项 II 给你一个有序数组 nums ,请你 原地 删除重复出现的元素,使得出现次数超过两次的元素只出现两次 ,返回删除后数组的新长度。 不要使用额外的数组空间,你必须在 原地 修改输入数组 并在使用 O(1) 额外空间的条件下完成。 说明: 为什么返回数值是整数,但输出的 ......
数组 II

【Leetcode】解题报告Day3~Day4

解题报告 Day3 1. 66. 加一 给定一个由 整数 组成的 非空 数组所表示的非负整数,在该数的基础上加一。 最高位数字存放在数组的首位, 数组中每个元素只存储单个数字。 你可以假设除了整数 0 之外,这个整数不会以零开头。 示例 1: 输入:digits = [1,2,3] 输出:[1,2, ......
Day Leetcode 报告 Day3 Day4

leetcode 将有序数组转换为二叉搜索树

给你一个整数数组 nums ,其中元素已经按 升序 排列,请你将其转换为一棵 高度平衡 二叉搜索树。 高度平衡 二叉树是一棵满足「每个节点的左右两个子树的高度差的绝对值不超过 1 」的二叉树。 示例 1: 输入:nums = [-10,-3,0,5,9] 输出:[0,-3,9,-10,null,5] ......
数组 leetcode

代码随想录算法训练营第8天| ● 344.反转字符串 ● 541. 反转字符串II ● 剑指Offer 05.替换空格 ● 151.翻转字符串里的单词 ● 剑指Offer58-II.左旋转字符串

344.反转字符串 mydemo--(一次就过)--(成功) class Solution { public: void reverseString(vector<char>& s) { int len = s.size(); char tmp; int i=0; int j = len-1; wh ......
字符串 字符 随想录 左旋 Offer

[LeetCode] 1352. Product of the Last K Numbers 最后 K 个数的乘积

Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream. Implement the ProductOfNumbers c ......
乘积 个数 LeetCode Product Numbers

Leetcode 1193. 每月交易Ⅰ

1193. 每月交易Ⅰ 题目 表:Transactions + + + | Column Name | Type | + + + | id | int | | country | varchar | | state | enum | | amount | int | | trans_date | d ......
Leetcode 1193

[LeetCode] 85. Maximal Rectangle_Hard tag: Dynamic Programming

Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example 1: Input: matri ......

leetcode 二叉树的最大深度

给定一个二叉树 root ,返回其最大深度。 二叉树的 最大深度 是指从根节点到最远叶子节点的最长路径上的节点数。 示例 1: 输入:root = [3,9,20,null,null,15,7] 输出:3 示例 2: 输入:root = [1,null,2] 输出:2 解题思路 这里可以转化思路为 ......
深度 leetcode

Fixed Autel IM608 II “The device is locked. Error code 106” Issue

Problem: When I was trying to use Autel IM608 II Key Programmer to read the 2016 BMW engine ECU ISN, it kept saying the prompt: “Abnormally detected. ......
device locked Fixed Autel Error

代码随想录算法训练营第7天| ● 454.四数相加II ● 383. 赎金信 ● 15. 三数之和 ● 18. 四数之和

454.两数相加 Ⅱ mydemo--(超时失败) class Solution { public: int fourSumCount(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3, vector<int>& nums4) { ......
之和 随想录 训练营 随想 算法

Leetcode(Hash)

1.the sum of two nums 1.1Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. 1.2 ......
Leetcode Hash

Leetcode 27. 移除元素

题目描述 给你一个数组 nums 和一个值 val,你需要 原地 移除所有数值等于 val 的元素,并返回移除后数组的新长度。 不要使用额外的数组空间,你必须仅使用 O(1) 额外空间并 原地 修改输入数组。 元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。 双指针 Python 实现 ......
Leetcode 元素 27

leetcode547省份数量

深度优先搜索 vector<bool>vis; int num=0; void dfs(vector<vector<int>>& isConnected,int x){ vis[x]=true; for(int i=0;i<isConnected[x].size();i++){ if(!vis[i] ......
省份 leetcode 数量 547

IIS上缺少 AspNetCoreModuleV2 如何解决

实际上是少了装了 .Net Core SDK 需要找到自己的程序使用的.Net Core对应版本进行下载 https://dotnet.microsoft.com/en-us/download/dotnet/3.0 只装 Hosting 就行了 ......

LeetCode -- 1462. 课程表 IV (拓扑排序,二进制集合)

本题我们要快速的判断一个点在拓扑序中是不是另一个点的前驱,先求出拓扑序,在利用二进制代表集合来进行前驱的判断。 class Solution { public: const static int N = 110, M = N * N; int h[N], e[M], ne[M], idx; int ......
课程表 拓扑 二进制 LeetCode 课程

算法训练day7 LeetCode454

算法训练day7: LeetCode454.383.15.18 454.四数相加 题目 454. 四数相加 II - 力扣(LeetCode) 题解 代码随想录 (programmercarl.com) class Solution { public: int fourSumCount(vector ......
算法 LeetCode day7 day 454