09 2022 档案

摘要:单调栈的定义与证明 前言 最近领悟到了单调栈的本质,特此来记录一下我的理解。 单调栈主要用来解决这样一类问题,当枚举到下标i,要求在下标i之前小于/大于val的数的下标中,找到最小/最大的下标位置。 一共有四种不同的情况,下面来证明在这四种情况中,栈内维护的元素始终单调递增或单调 阅读全文
posted @ 2022-09-28 18:55 onlyblues 阅读(852) 评论(0) 推荐(0) 编辑
摘要:Find All Good Indices You are given a 0-indexed integer array nums of size n and a positive integer k. We call an index i in the range $k \leq i 阅读全文
posted @ 2022-09-25 16:33 onlyblues 阅读(19) 评论(0) 推荐(0) 编辑
摘要:Longest Subarray With Maximum Bitwise AND You are given an integer array nums of size n. Consider a non-empty subarray from nums that has the maximu 阅读全文
posted @ 2022-09-25 16:07 onlyblues 阅读(45) 评论(0) 推荐(0) 编辑
摘要:旅行 给定一个 n 个节点的树,节点编号为 1n。 请你从中选择一个简单路径(不能包含重复节点或重复的边),并沿所选路径来一场旅行,更具体的说,就是从所选路径的一个端点沿路径前往另一个端点。 注意,所选简单路径可以只由一个节点组成。 旅行需要花费能量。 初始时,你的能量为 0 阅读全文
posted @ 2022-09-25 15:08 onlyblues 阅读(50) 评论(0) 推荐(0) 编辑
摘要:减法操作 给定一个包含 n 个非负整数的数列 a1,a2,,an。 你可以对该数列进行以下两种减法操作: 任选其中一个元素,并将该元素的值减去 2。 任选两个相邻元素,并将两个元素的值各减去 1。 请你判断,能否经过一系列减法操作,使得数列中的所有元素都变为 $0 阅读全文
posted @ 2022-09-25 14:05 onlyblues 阅读(62) 评论(0) 推荐(0) 编辑
摘要:分成互质组 给定 n 个正整数,将它们分组,使得每组中任意两个数互质。 至少要分成多少个组? 输入格式 第一行是一个正整数 n。 第二行是 n 个不大于 10000 的正整数。 输出格式 一个正整数,即最少需要的组数。 数据范围 1n10 输入样例: 6 阅读全文
posted @ 2022-09-21 21:03 onlyblues 阅读(426) 评论(0) 推荐(0) 编辑
摘要:Sum of Prefix Scores of Strings You are given an array words of sizeco n sisting of non-empty strings. We define the score of a string word as the n 阅读全文
posted @ 2022-09-19 20:43 onlyblues 阅读(64) 评论(0) 推荐(0) 编辑
摘要:Minimum Money Required Before Transactions You are given a 0-indexed 2D integer array transactions , where transactions[i] = [costi, cashbacki] . The 阅读全文
posted @ 2022-09-19 19:44 onlyblues 阅读(32) 评论(0) 推荐(0) 编辑
摘要:Smallest Subarrays With Maximum Bitwise OR You are given a 0-indexed array nums of length n, consisting of non-negative integers. For each index i 阅读全文
posted @ 2022-09-18 19:36 onlyblues 阅读(56) 评论(0) 推荐(0) 编辑
摘要:解方程 给定一个非负整数 a,请你计算方程 a(ax)x=0 的非负整数解的数量。 其中 指按位异或。 输入格式 第一行包含整数 T,表示共有 T 组测试数据。 每组数据占一行,包含一个非负整数 a。 输出格式 每组数据输出一行结果,一个整数 阅读全文
posted @ 2022-09-18 15:43 onlyblues 阅读(164) 评论(0) 推荐(0) 编辑
摘要:击中战舰 李华在玩一款叫做《海战》的小游戏,下面是游戏介绍。 给定一个 1×n 的方格矩阵,方格从左到右依次编号为 1n。 在这个方格矩阵中,隐藏着 a 个战舰。 每个战舰都占据 b 个连续的方格,每个方格最多只能被一个战舰占据。 每个战舰的具体位置未知。 阅读全文
posted @ 2022-09-18 09:16 onlyblues 阅读(26) 评论(0) 推荐(0) 编辑
摘要:匹配价值 给定一个字符串集合 SS 中包含 m 个长度为 n01 字符串,集合中可能包含重复元素。 给定一个长度为 n 的整数序列 w1,w2,,wn。 关于两个长度为 n01 字符串 s,t 的匹配价值 V,其具体计算方 阅读全文
posted @ 2022-09-14 09:02 onlyblues 阅读(38) 评论(0) 推荐(0) 编辑
摘要:最长上升子序列 给定一个长度为 N 的数列,求数值严格单调递增的子序列的长度最长是多少。 输入格式 第一行包含整数 N。 第二行包含 N 个整数,表示完整序列。 输出格式 输出一个整数,表示最大长度。 数据范围 1N1000,${−10}^{9} \leq \ 阅读全文
posted @ 2022-09-13 16:24 onlyblues 阅读(881) 评论(0) 推荐(0) 编辑
摘要:原文链接: https://www.acwing.com/file_system/file/content/whole/index/content/6489818/ 想必很多同学在接触递归算法的时候都会很困惑,比如归并排序,为什么下面的代码可以将一个序列排好序呢? 今天突然发现,递归过程的本质就是数 阅读全文
posted @ 2022-09-09 16:43 onlyblues 阅读(81) 评论(0) 推荐(0) 编辑
摘要:Evaluate Division You are given an array of variable pairs equations and an array of real numbers values , where equations[i] = [Ai, Bi] and values[i] 阅读全文
posted @ 2022-09-07 21:23 onlyblues 阅读(22) 评论(0) 推荐(0) 编辑
摘要:Count Unique Characters of All Substrings of a Given String Let's define a function countUniqueChars(s) that returns the number of unique characters o 阅读全文
posted @ 2022-09-06 16:16 onlyblues 阅读(30) 评论(0) 推荐(0) 编辑
摘要:Meeting Rooms III You are given an integer n. There are n rooms numbered from 0 to n1. You are given a 2D integer array meetings where meet 阅读全文
posted @ 2022-09-05 23:19 onlyblues 阅读(88) 评论(0) 推荐(0) 编辑
摘要:Number of Ways to Reach a Position After Exactly k Steps You are given two positive integers startPos and endPos . Initially, you are standing at posi 阅读全文
posted @ 2022-09-05 20:16 onlyblues 阅读(69) 评论(0) 推荐(0) 编辑
摘要:Maximum Number of Robots Within Budget You have n robots. You are given two 0-indexed integer arrays, chargeTimes and runningCosts , both of length 阅读全文
posted @ 2022-09-04 21:47 onlyblues 阅读(50) 评论(0) 推荐(0) 编辑
摘要:串联数字 给定 n 个正整数 a1,a2,,an。 我们规定将正整数 aiaj 串联是指将 aj 直接接在 ai 后面构成一个新整数。 例如,1234 串联得到 12343412 串联得到 3412。 现 阅读全文
posted @ 2022-09-04 16:23 onlyblues 阅读(81) 评论(0) 推荐(0) 编辑
摘要:列表排序 给定一个 nm 列的整数列表。 列表中每一行的 m 个整数都是一个 1m 的排列。 现在,你可以对该列表执行以下两种操作: 选择一行中的两个整数并交换它们。此操作,每行最多只能执行一次。 选择列表中的两列并交换它们。此操作,最多只能执行一次。 不难发现,你 阅读全文
posted @ 2022-09-04 09:22 onlyblues 阅读(82) 评论(0) 推荐(0) 编辑
摘要:环形石子合并 将 n 堆石子绕圆形操场排放,现要将石子有序地合并成一堆。 规定每次只能选相邻的两堆合并成新的一堆,并将新的一堆的石子数记做该次合并的得分。 请编写一个程序,读入堆数 n 及每堆的石子数,并进行如下计算: 选择一种合并石子的方案,使得做 n1 次合并得分总和最大。 选择一 阅读全文
posted @ 2022-09-02 20:55 onlyblues 阅读(203) 评论(0) 推荐(1) 编辑

Web Analytics
点击右上角即可分享
微信分享提示