leetcode 45 ii

洛谷 P9139 [THUPC 2023 初赛] - 喵了个喵 II

考虑如果每个数恰好出现两次,那么容易得出一个序列合法当且仅当将每个数两次出现位置看作一个区间 $[l_i,r_i]$ 的两个端点,那么这些区间两两之间不存在包含关系。 考虑每个数出现四次的情况,我们钦定两次为 $i$,两次为 $i+n$,这样可以转化为 $2n$ 的情况,而容易发现只有 $1122$ ......
初赛 P9139 THUPC 9139 2023

leetcode-1518-easy

Water Bottles ``` There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the marke ......
leetcode 1518 easy

A+B 输入输出练习II

题目描述 你的任务是计算a+b。 输入 第一行是一个整数N,表示后面会有N行a和b,通过空格隔开。 输出 对于输入的每对a和b,你需要在相应的行输出a、b的和。 如第二对a和b,对应的和也输出在第二行。 样例输入 2 1 5 10 20 样例输出 6 30 代码 #include <stdio.h> ......

Luogu 3412 仓鼠找sugar II

你也许说得对,但我是真看不懂第一篇题解那个答案式子…… 预处理是差不多的。 设 $f_u$ 表示从 $u\to fa(u)$ 的期望步数,$g_u$ 为 $fa(u)\to u$ 的期望步数,$d_u$ 为 $u$ 的度数。 那么显然有: $$f_u=\frac{1}{d_u}\left(1+\su ......
仓鼠 Luogu sugar 3412 II

Luogu 6177 Count on a tree II/【模板】树分块

分块,但是带 $\log$。 先离散化,然后值域就变成 $O(n)$ 的了。 我们先对每个点维护一个 `bitset`,那么显然答案就是 $u$ 到 $v$ 路径上所有点的 `bitset` 或起来后 $1$ 的个数。 然后可以树链剖分,把链拍成序列,并且对树链剖分后的 `dfs` 序维护 $\sq ......
模板 Luogu Count 6177 tree

Codility / LeetCode的重要性与注意事项

Codility / Leetcode 不只会针对回答内容给出最终分数,也会一并记录解题的过程供面试官参考; 相较于现场考试,Codility / Leetcode可以省下更多时间,也能让求职者在最熟悉的环境发挥实力。 进行测验前 先查看Codility / Leetcode FAQ,并完成demo ......

代码随想录算法训练营第三十四天| 完全背包 518. 零钱兑换 II 377. 组合总和 Ⅳ

完全背包 区别: 每种物品都是可以无线多个 代码: 1 // 多背包问题 2 // 有N个物品,他们的体积和重量如下,但是这些物品有无限个 3 // 需要发挥背包的最大容量,来让价值最大 4 // 5 // dp[n]: 当容量为N的时候,背包的价值最大是多少 6 // dp[n]: 7 // dp ......
随想录 零钱 训练营 总和 随想

[LeetCode] 2268. Minimum Number of Keypresses

You have a keypad with 9 buttons, numbered from 1 to 9, each mapped to lowercase English letters. You can choose which characters each button is match ......
Keypresses LeetCode Minimum Number 2268

[LeetCode] 2323. Find Minimum Time to Finish All Jobs II

You are given two 0-indexed integer arrays jobs and workers of equal length, where jobs[i] is the amount of time needed to complete the ith job, and w ......
LeetCode Minimum Finish 2323 Find

[LeetCode] 2330. Valid Palindrome IV

You are given a 0-indexed string s consisting of only lowercase English letters. In one operation, you can change any character of s to any other char ......
Palindrome LeetCode Valid 2330 IV

[LeetCode] 2340. Minimum Adjacent Swaps to Make a Valid Array

You are given a 0-indexed integer array nums. Swaps of adjacent elements are able to be performed on nums. A valid array meets the following condition ......
LeetCode Adjacent Minimum Array Swaps

[LeetCode] 2422. Merge Operations to Turn Array Into a Palindrome

You are given an array nums consisting of positive integers. You can perform the following operation on the array any number of times: Choose any two  ......
Operations Palindrome LeetCode Array Merge

[LeetCode] 1676. Lowest Common Ancestor of a Binary Tree IV

Given the root of a binary tree and an array of TreeNode objects nodes, return the lowest common ancestor (LCA) of all the nodes in nodes. All the nod ......
LeetCode Ancestor Common Binary Lowest

LeetCode之0661, 二维向量初始化

img[i][j]周围的单元格,img[i+i1][j+j1], i1=-1,0,1, j1=-1,0,1, 每个都判断一次。O(9*m*n) class Solution { public: std::vector<std::vector<int>> imageSmoother( std::vec ......
向量 LeetCode 0661

Leetcode之0709, 修改字符串

1 class Solution { 2 public: 3 string toLowerCase(string s) { 4 for(char &ch: s){ 5 if(ch>='A' && ch<='Z'){ 6 ch=tolower(ch); 7 } 8 } 9 return s; 10 } ......
字符串 字符 Leetcode 0709

[LeetCode] 2486. Append Characters to String to Make Subsequence

You are given two strings s and t consisting of only lowercase English letters. Return the minimum number of characters that need to be appended to th ......

[刷题记录Day4]Leetcode链表专题

# No.1 ## 题目 [两两交换链表中的节点](https://leetcode.cn/problems/swap-nodes-in-pairs/) ## 思路 - 模拟类型题目 - 两个节点前后交换,同时记住原来的下一个节点 - 虚拟头节点 ## 代码 ```Java public ListN ......
Leetcode 专题 Day4 Day

LeetCode 1201. Ugly Number III 数学+二分答案

An ugly number is a positive integer that is divisible by $a$, $b$, or $c$. Given four integers $n$, $a$, $b$, and $c$, return the $n$th ugly number. ......
LeetCode 答案 数学 Number 1201

LeetCode 875. Koko Eating Bananas 二分答案

Koko loves to eat bananas. There are $n$ piles of bananas, the $i$th pile has $piles[i]$ bananas. The guards have gone and will come back in `h` hours ......
LeetCode 答案 Bananas Eating Koko

Win11 将网站发布到IIS 遇到 HTTP Error 500.19 code 0x8007000d, web.config 文件有错误

当我们在IIS 发布网站时,遇到 HTTP Error 500.19 code 0x8007000d, web.config 文件有错误。 有可能是 web.config 文件指定了module: AspNetCoreModuleV2 ,但我们的机器没有安装。可尝试按照如下方式安装对应版本的IIS支 ......
错误 8007000 文件 500.19 config

iis日志分析

1、工具Log Parser ,命令行把日志文件导入数据库: logparser "SELECT *, TO_LOCALTIME(TO_TIMESTAMP(ADD(TO_STRING(date, 'yyyy-MM-dd '), TO_STRING(time, 'hh:mm:ss')),'yyyy-M ......
日志 iis

LeetCode 1011. Capacity To Ship Packages Within D Days 二分答案

A conveyor belt has packages that must be shipped from one port to another within `days` days. The ith package on the conveyor belt has a weight of $w ......
LeetCode Capacity Packages 答案 Within

leetcode练习

## 分类 题单:[code](#code) 难度:[简单](#Simple) [中等](#middle) [困难](#hard) 类型:[数组](#数组) [链表](#链表) [字符串](#字符串) [二叉树](#二叉树) [排序](#排序) 解法:[递归和迭代](#递归和迭代) [滑动窗口 ]( ......
leetcode

leetcode 546. 移除盒子

1. 题目 读题 链接:https://www.nowcoder.com/questionTerminal/a5390d76441647fbb182f34bee6a1ca7来源:牛客网一维消消乐 小v在vivo手机的应用商店中下载了一款名为“一维消消乐”的游戏,介绍如下: 1、给出一些不同颜色的豆子 ......
盒子 leetcode 546

[LeetCode] 2461. Maximum Sum of Distinct Subarrays With Length K

You are given an integer array nums and an integer k. Find the maximum subarray sum of all the subarrays of nums that meet the following conditions: T ......
Subarrays LeetCode Distinct Maximum Length

[LeetCode] 2222. Number of Ways to Select Buildings

You are given a 0-indexed binary string s which represents the types of buildings along a street where: s[i] = '0' denotes that the ith building is an ......
Buildings LeetCode Number Select 2222

Leetcode日记

| 日期 | 题号 | 题目 | 解法 | 难度 | | | | | | | | 2023-07-11 | 2741 | [给定一个互不相同的正整数数组,找出**特别排列**(相邻元素互模任一为0)的总数目。取余](https://leetcode.cn/problems/special-permu ......
Leetcode 日记

代码随想录算法训练营第三十三天| 1049. 最后一块石头的重量 II 494. 目标和 474.一和零

1049. 最后一块石头的重量 II 思路: 因为含有两个石头的相撞,所以需要把dp的目标值改成sum/2, 然后取得这个目标值的最大值,然后对sum-2*target 代码: 1 // 要求:有多个石头,两两撞击,取得剩下的石头的最小值 2 // ——》一定要碰到最后一个 3 // 注意: 4 / ......
随想录 训练营 随想 算法 重量

2069. 模拟行走机器人 II (Medium)

问题描述 2069. 模拟行走机器人 II (Medium) 给你一个在 XY 平面上的 width x height 的网格图, 左下角 的格子为 (0, 0) , 右上角 的格子 为 (width - 1, height - 1) 。网格图中相邻格子为四个基本方向之一( "North", "Ea ......
机器人 机器 Medium 2069 II

2069. Walking Robot Simulation II (Medium)

Description 2069. Walking Robot Simulation II (Medium) A width x height grid is on an XY-plane with the bottom-left cell at (0, 0) and the top-right c ......
Simulation Walking Medium Robot 2069