随笔分类 - 算法-刷题题目
牛客,leetcode,codeforces
摘要:https://leetcode.cn/problems/number-of-subarrays-that-match-a-pattern-ii/description/ 给你一个下标从\(0\)开始长度为\(n\)的整数数组\(nums\),和一个下标从\(0\)开始长度为\(m\)的整数数组\(
阅读全文
posted @ 2024-02-27 17:30
lipu123
摘要:链接:https://ac.nowcoder.com/acm/problem/254017 来源:牛客网 问题描述: 游游拿到了一个数字串,她想取一个该数字串的子序列(子序列在原串中可以不连续),使得该子序列是9的倍数。子序列可以包含前导零。 游游想知道,一共能取多少个合法的子序列?答案请对 \(1
阅读全文
posted @ 2024-01-25 20:10
lipu123
摘要:链接:https://ac.nowcoder.com/acm/contest/73202/B 来源:牛客网 问题描述 有三种数量无限的砝码和一个天平,天平的一端有一个质量为\(m\)的物品,问能否通过放置砝码使得天平平衡? 输入描述: 第一行包含一个整数 \(T \ (1 \leq T \leq 1
阅读全文
posted @ 2024-01-17 16:33
lipu123
摘要:https://leetcode.cn/problems/find-beautiful-indices-in-the-given-array-ii/description/ 给你一个下标从 \(0\) 开始的字符串\(s\) 、字符串 \(a\) 、字符串 \(b\) 和一个整数 \(k\) 。 如
阅读全文
posted @ 2024-01-17 11:46
lipu123
摘要:链接:https://ac.nowcoder.com/acm/problem/259733 来源:牛客网 问题描述 小美定义一个数组的权值为:数组中任选两个数的异或之和。例如,数组[2,1,3]的权值为:\((2 xor 1)+(2 xor 3)+(1 xor 3)=3+1+2=6\)。 小美拿到了
阅读全文
posted @ 2024-01-15 21:41
lipu123
摘要:链接:https://ac.nowcoder.com/acm/problem/261577 来源:牛客网 问题 小美在玩游戏,游戏中有\(n\)个怪物,怪物的血量为\(h_i\),攻击力为\(a_i\)。小美的血量为 \(H\),攻击力为 \(A\),小美可以击败血量和攻击力都小于自己的怪物,并且打
阅读全文
posted @ 2024-01-15 19:17
lipu123
摘要:https://leetcode.cn/problems/path-with-minimum-effort/description/ 你准备参加一场远足活动。给你一个二维\(rows x columns\)的地图\(heights\),其中\(heights[row][col]\)表示格子\((ro
阅读全文
posted @ 2024-01-10 11:49
lipu123
摘要:使 X 和 Y 相等的最少操作次数 https://leetcode.cn/problems/minimum-number-of-operations-to-make-x-and-y-equal/description/ 给你两个正整数 x 和 y 。 一次操作中,你可以执行以下四种操作之一: 如果
阅读全文
posted @ 2024-01-08 21:29
lipu123
摘要:链接:https://ac.nowcoder.com/acm/contest/72980/C 来源:牛客网 小菜鸡今天在打某款 ingteresting 的游戏。每当他通关游戏的某一关卡,该关卡的累计得分值就会增加 \(\mathrm{x}\)。由于\(\mathrm{x}\) 是一个正实数,因此存
阅读全文
posted @ 2024-01-08 15:04
lipu123
摘要:https://blog.csdn.net/m0_73896521/article/details/135308235 Problem Statement You are given a sequence \(A=(A_1,A_2,…,A_N)\) of length\(N\). Respond t
阅读全文
posted @ 2024-01-04 11:26
lipu123
摘要:https://atcoder.jp/contests/abc330/tasks/abc330_d Problem Statement You are given an\(N \times N\)grid. Let\((i,j)\)denote the cell in the i-th row fr
阅读全文
posted @ 2024-01-03 20:51
lipu123
摘要:https://leetcode.cn/problems/find-longest-special-substring-that-occurs-thrice-ii/description/ 给你一个仅由小写英文字母组成的字符串\(s\)。 如果一个字符串仅由单一字符组成,那么它被称为 特殊 字符串。
阅读全文
posted @ 2024-01-02 20:47
lipu123
摘要:链接:https://ac.nowcoder.com/acm/contest/72779/C 来源:牛客网 小红来到了一片沼泽地的岸边,她希望能通过这片沼泽地。 这个沼泽地地图用一个矩阵进行表示。1代表沼泽,0代表平地。小红刚开始在矩阵的左上角,她需要从右下角离开地图。已知进入地图和离开地图的时间可
阅读全文
posted @ 2024-01-02 20:37
lipu123
摘要:二叉树的右视图 给定一个二叉树的 根节点 root,想象自己站在它的右侧,按照从顶部到底部的顺序,返回从右侧所能看到的节点值。 示例 1: 输入: [1,2,3,null,5,null,4] 输出: [1,3,4] 示例 2: 输入: [1,null,3] 输出: [1,3] 示例 3: 输入: [
阅读全文
posted @ 2023-12-29 17:29
lipu123
摘要:给定一个长度为\(n\)的整数数组\(height\)。有\(n\)条垂线,第\(i\)条线的两个端点是\((i,0)\)和\((i,height[i])\)。 找出其中的两条线,使得它们与\(x\)轴共同构成的容器可以容纳最多的水。 返回容器可以储存的最大水量。 说明:你不能倾斜容器。 示例 1:
阅读全文
posted @ 2023-12-28 10:33
lipu123
摘要:https://leetcode.cn/problems/shortest-bridge/description/ 给你一个大小为\(n \times n\)的二元矩阵\(grid\),其中\(1\)表示陆地,\(0\)表示水域。 岛是由四面相连的 1 形成的一个最大组,即不会与非组内的任何其他 1
阅读全文
posted @ 2023-12-25 21:01
lipu123
摘要:链接:https://ac.nowcoder.com/acm/contest/72041/D 来源:牛客网 小冰老是搞不清楚子串和子序列的区别,小天想要帮助小冰区分子串和子序列,小天告诉小冰,子串是连续的,子序列不一定连续,在一个字符串中,如果确定了子串的首和尾,那么子串就确定了。而子序列却不一定。
阅读全文
posted @ 2023-12-16 21:58
lipu123
摘要:你这个学期必须选修 numCourses 门课程,记为 0 到 numCourses - 1 。 在选修某些课程之前需要一些先修课程。 先修课程按数组 prerequisites 给出,其中 prerequisites[i] = [ai, bi] ,表示如果要学习课程 ai 则 必须 先学习课程 b
阅读全文
posted @ 2023-12-14 11:34
lipu123
摘要:https://leetcode.cn/problems/count-subarrays-where-max-element-appears-at-least-k-times/description/ 给你一个整数数组 nums 和一个 正整数 k 。 请你统计有多少满足「nums 中的最大元素」至
阅读全文
posted @ 2023-12-13 17:38
lipu123
摘要:假设有打乱顺序的一群人站成一个队列,数组 people 表示队列中一些人的属性(不一定按顺序)。每个 \(people[i] = [h_i, k_i]\)表示第\(i\)个人的身高为\(h_i\),前面 正好 有\(k_i\)个身高大于或等于\(h_i\)的人。 请你重新构造并返回输入数组\(peo
阅读全文
posted @ 2023-12-12 19:56
lipu123