leetcode detonate maximum bombs

Leetcode 151. 反转字符串中的单词(Reverse words in a string)

[题目链接](https://leetcode.cn/problems/reverse-words-in-a-string) 给你一个字符串 s ,请你反转字符串中 单词 的顺序。 单词 是由非空格字符组成的字符串。s 中使用至少一个空格将字符串中的 单词 分隔开。 返回 单词 顺序颠倒且 单词 之 ......
字符串 单词 字符 Leetcode Reverse

LeetCode46全排列(回溯入门)

### 欢迎访问我的GitHub > 这里分类和汇总了欣宸的全部原创(含配套源码):[https://github.com/zq2599/blog_demos](https://github.com/zq2599/blog_demos) ### 题目描述 - 难度:中等 - 给定一个不含重复数字的数 ......
LeetCode 46

[LeetCode] 2240. Number of Ways to Buy Pens and Pencils

You are given an integer total indicating the amount of money you have. You are also given two integers cost1 and cost2 indicating the price of a pen ......
LeetCode Pencils Number 2240 Ways

Leetcode 24. 两两交换链表中的节点(Swap nodes in pairs)

[题目链接](https://leetcode.cn/problems/swap-nodes-in-pairsn/) 给你一个链表,两两交换其中相邻的节点,并返回交换后链表的头节点。你必须在不修改节点内部的值的情况下完成本题(即,只能进行节点交换)。 示例 1: ![](https://img202 ......
节点 Leetcode nodes pairs Swap

[LeetCode][338]counting-bits

# Content Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary repres ......
counting-bits LeetCode counting bits 338

[LeetCode][337]house-robber-iii

# Content The thief has found himself a new place for his thievery again. There is only one entrance to this area, called root. Besides the root, each ......
house-robber-iii LeetCode robber house 337

[LeetCode][322]coin-change

# Content You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of mone ......
coin-change LeetCode change coin 322

[LeetCode][312]burst-balloons

# Content You are given n balloons, indexed from 0 to n - 1. Each balloon is painted with a number on it represented by an array nums. You are asked t ......
burst-balloons LeetCode balloons burst 312

[LeetCode] 2483. Minimum Penalty for a Shop

You are given the customer visit log of a shop represented by a 0-indexed string customers consisting only of characters 'N' and 'Y': if the ith chara ......
LeetCode Minimum Penalty 2483 Shop

leetcode & c++多线程刷题日志

## 1.按序打印 [按序打印](https://leetcode.cn/problems/print-in-order/description/) **解法** + 1. 互斥锁 ```c++ class Foo { mutex mtx1, mtx2; public: Foo() { mtx1.l ......
线程 leetcode 日志 amp

Leetcode刷题笔记——单调性

## 单调性 单调性是数学中使用的一种常见性质,通常用于描述函数,在高等数学中的定义常常为: 设函数f(x)在区间I上有定义,如果对于I上的任意两个数x1和x2,当x1f(x2)),则称函数f(x)在区间I上是单调递增的(或者单调递减的)。 例如如下图像就是两个单调函数。 ![](https://i ......
Leetcode 笔记

Leetcode 剑指Offer 05. 替换空格(Ti huan kong ge lcof)

[题目链接](https://leetcode.cn/problems/ti-huan-kong-ge-lcof) 请实现一个函数,把字符串 s 中的每个空格替换成"%20"。 示例 1: ``` 输入:s = "We are happy." 输出:"We%20are%20happy." ``` 提 ......
空格 Leetcode Offer huan kong

[LeetCode][309]best-time-to-buy-and-sell-stock-with-cooldown

# Content You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may ......

[LeetCode 11]盛最多水的容器 二分

emmm看到这题第一反应是二分_(:з」∠)_ 首先可以观察到,假设我们目前敲定了2块板l和r,那么在l和r之间,低于l和r的板子都是无效的(这个应该显而易见)。 基于这个性质对无效板进行消除,最后会得到一个山峰形(先单调不降,后单调不升) 现在考虑对山峰形如何求解。 考虑枚举每个有效板作为边界,寻 ......
容器 LeetCode 11

Leetcode刷题之 1071. 字符串的最大公因子

# 题目描述 对于字符串 s 和 t,只有在 s = t + ... + t(t 自身连接 1 次或多次)时,我们才认定 “t 能除尽 s”。 给定两个字符串 str1 和 str2 。返回 最长字符串 x,要求满足 x 能除尽 str1 且 x 能除尽 str2 。 示例 1: 输入:str1 = ......
因子 字符串 字符 Leetcode 1071

【CF1519D】Maximum Sum of Products

```cpp #include using namespace std; typedef long long ll; ll n,a[5000+10],b[5000+10],abpre[5000+10],absuf[5000+10],ans; int main(){ cin >> n; for(ll ......
Products Maximum 1519D 1519 Sum

Codeforces Round 892 (Div. 2)E. Maximum Monogonosity(动态规划,数学)

题目链接:https://codeforces.com/contest/1859/problem/E 题意: 有长度为n的a和b俩个序列,定义f【l,r】 = abs(a【l】-b【r】) + abs(b【l】-a【r】); 给正整数k,求 不相交 的 区间 且 所有 区间的长度 的 和 为 k 的 ......

[LeetCode][300]longest-increasing-subsequence

# Content Given an integer array nums, return the length of the longest strictly increasing subsequence. Example 1: Input: nums = [10,9,2,5,3,7,101,18 ......

Leetcode 15. 三数之和(3Sum)

[题目链接](https://leetcode.cn/problems/3sum) 给你一个整数数组 nums ,判断是否存在三元组 [nums[i], nums[j], nums[k]] 满足 i != j、i != k 且 j != k ,同时还满足 nums[i] + nums[j] + nu ......
之和 Leetcode 3Sum Sum 15

Leetcode2788——按分隔符拆分字符串

给你一个字符串数组 words 和一个字符 separator ,请你按 separator 拆分 words 中的每个字符串。 返回一个由拆分后的新字符串组成的字符串数组,不包括空字符串 。 注意 separator 用于决定拆分发生的位置,但它不包含在结果字符串中。 拆分可能形成两个以上的字符串 ......
分隔符 字符串 字符 Leetcode 2788

LeetCode 周赛上分之旅 #42 当 LeetCode 考树上倍增,出题的趋势在变化吗

> ⭐️ **本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 \[彭旭锐] 和 [BaguTree Pro](https://www.mdnice.com/writing/85b28c4e60354865a423728e668fc570) 知识星球提问。** > > 学习数据 ......
LeetCode 趋势 之旅 42

Leetcode 55

class Solution: def canJump(self, nums: List[int]) -> bool: if len(nums) == 1:return True i = 0;j = i for i in range(100000): if j > i+nums[i]:pass el ......
Leetcode 55

Leetcode 383. 赎金信(Ransom note)

[题目链接](https://leetcode.cn/problems/ransom-note) 给你两个字符串:ransomNote 和 magazine ,判断 ransomNote 能不能由 magazine 里面的字符构成。 如果可以,返回 true ;否则返回 false 。 magazi ......
Leetcode Ransom note 383

LeetCode.283 移动零

题目描述 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 请注意 ,必须在不复制数组的情况下原地对数组进行操作。 https://leetcode.cn/problems/move-zeroes/description/ 输入: nums = [0,1 ......
LeetCode 283

Leetcode_485. 最大连续 1 的个数

题目描述 给定一个二进制数组, 计算其中最大连续 1 的个数。 示例: 输入:[1,1,0,1,1,1] 输出:3 解释:开头的两位和最后的三位都是连续 1 ,所以最大连续 1 的个数是 3. 提示: 输入的数组只包含 0 和 1 。 输入数组的长度是正整数,且不超过 10,000。 参考实现 示例 ......
个数 Leetcode 485

[刷题记录Day22]Leetcode二叉树

# No.1 ## 题目 [二叉搜索树的最近公共祖先](https://leetcode.cn/problems/lowest-common-ancestor-of-a-binary-search-tree/) ## 思路 - 递归法 - BST特性如何利用?在BST中,公共祖先一定在p、q数值范围 ......
Leetcode Day 22

leetcode 题库994——bfs典型解法(队列+递归实现)

class Solution: def orangesRotting(self, grid: list[list[int]]) -> int: m,n=len(grid),len(grid[0]) queue,good=[],[] def bfs(queue,good,m,n,grid): time ......
解法 队列 题库 leetcode 典型

LeetCode题库77.组合——dfs典型解法,递归+回溯+剪枝

class Solution: def combine(self, n: int, k: int): nums=[x+1 for x in range(n)] res,ans=[],[] def dfs(nums:list[int]): if len(ans)==k: ans_copy=ans.co ......
解法 题库 LeetCode 典型 dfs

leetcode_35. 搜索插入位置

题目描述 35. 搜索插入位置 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 请必须使用时间复杂度为 O(log n) 的算法。 输入: nums = [1,3,5,6], target = 5 输出: 2 输入: nums ......
leetcode 位置 35

LeetCode —— 排序

148. 排序链表 一般都用归并排序,因为是单向链表,其它排序算法根据下标找元素,向前遍历等都比较困难 主函数流程是: 如果 head==null || head.next==null return head。因为 head.next == null 即只有一个元素时,不用再划分了,而且一个元素本身 ......
LeetCode