随笔分类 - 算法-刷题题目 / 力扣+acwing
摘要:https://leetcode.cn/problems/shortest-distance-after-road-addition-queries-i/description/ 这个题分两个版本,一个简单的,一个困难的。 给你一个整数 和一个二维整数数组 。 有\(
阅读全文
摘要:给你一个长度为的整数数组,是 偶数 ,同时给你一个整数 。 你可以对数组进行一些操作。每次操作中,你可以将数组中 任一 元素替换为到之间的 任一 整数。 执行完所有操作以后,你需要确保最后得到的数组满足以下条件: 存在一个整数\(X\
阅读全文
摘要:https://www.luogu.com.cn/problem/P2758 https://leetcode.cn/problems/edit-distance/description/ 设 和 是两个字符串。我们要用最少的字符操作次数,将字符串 转换为字符串
阅读全文
摘要:https://leetcode.cn/problems/maximize-total-cost-of-alternating-subarrays/description/ 给你一个长度为的整数数组。 子数组(其中\(0 <= l <= r <
阅读全文
摘要:https://leetcode.cn/problems/search-in-rotated-sorted-array/description/ 整数数组nums按升序排列,数组中的值 互不相同 。 在传递给函数之前,nums 在预先未知的某个下标\(k(0 <= k < nums.length)\
阅读全文
摘要:https://leetcode.cn/problems/maximum-total-damage-with-spell-casting/description/ 一个魔法师有许多不同的咒语。 给你一个数组,其中每个元素表示一个咒语的伤害值,可能会有多个咒语有相同的伤害值。 已知魔
阅读全文
摘要:这种题一个套路问题 https://www.cnblogs.com/lipu123/p/15435169.html 几乎每一个人都用 乘法表。但是你能在乘法表中快速找到第 k 小的数字吗? 乘法表是大小为的一个整数矩阵,其中(下标从 1
阅读全文
摘要:https://leetcode.cn/problems/shortest-path-with-alternating-colors/?envType=study-plan-v2&envId=graph-theory 给定一个整数,即有向图中的节点数,其中节点标记为到\(n -
阅读全文
摘要:https://leetcode.cn/problems/continuous-subarray-sum/ 给你一个整数数组和一个整数,编写一个函数来判断该数组是否含有同时满足下述条件的连续子数组: 子数组大小 至少为,且 子数组元素总和为的倍数。 如果
阅读全文
摘要:https://leetcode.cn/problems/count-pairs-of-connectable-servers-in-a-weighted-tree-network/description/ 给你一棵无根带权树,树中总共有 n 个节点,分别表示 n 个服务器,服务器从 0 到 n -
阅读全文
摘要:给你一个下标从 0 开始的字符串word 和一个整数k。 在每一秒,你必须执行以下操作: 移除word的前k个字符。 在word的末尾添加k个任意字符。 注意添加的字符不必和移除的字符相同。但是,必须在每一秒钟都执行两种操作。 返回将word恢复到其初始状态所需的最短时间(该时间必须大于零)。 示例
阅读全文
摘要:https://leetcode.cn/problems/number-of-subarrays-that-match-a-pattern-ii/description/ 给你一个下标从开始长度为的整数数组,和一个下标从开始长度为的整数数组\(
阅读全文