随笔分类 - 算法基础—尺取法
摘要:76. 最小覆盖子串 难度困难1312 给你一个字符串 s 、一个字符串 t 。返回 s 中涵盖 t 所有字符的最小子串。如果 s 中不存在涵盖 t 所有字符的子串,则返回空字符串 "" 。 注意: 对于 t 中重复字符,我们寻找的子字符串中该字符数量必须不少于 t 中该字符数量。 如果 s 中存在
阅读全文
摘要:题目描述 在数轴上有 n个闭区间从 1 至 n 编号,第 i 个闭区间为 [li,ri][l**i,r**i] 。 现在要从中选出 m 个区间,使得这 m 个区间共同包含至少一个位置。换句话说,就是使得存在一个 x ,使得对于每一个被选中的区间 [li,ri][l**i,r**i],都有 li≤x≤
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/9982/F 来源:牛客网 牛牛有一个数组,数组元素是1到n的排列,即数组的值在1~n范围内,且每个数字仅出现1次。 牛牛想要将该数组变为升序排列的,他可以进行如下的操作。 首先他要确定一个长度k,k的范围在1~n之间。
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/11746 好久没写过代码了,思维能力下降,爬了 A. 切蛋糕 待补 B. 小宝的幸运数组 套路题,初始化tmp为0,从头遍历一遍数组,用tmp加上当前a[i]再对k取模,如果有两个位置得到的模数一样,说明这一段的和就是k的倍数
阅读全文
摘要:Kolya got an integer array a1,a2,…,an. The array can contain both positive and negative integers, but Kolya doesn't like 0 , so the array doesn't cont
阅读全文
摘要:Today is Jaime’s birthday and, to celebrate, his friends ordered a cake decorated with eggfruits and persimmons. When the cake arrived, to their surpr
阅读全文
摘要:Tokitsukaze has a sequence of length n, denoted by a . Tokitsukaze can merge two consecutive elements of a as many times as she wants. After each oper
阅读全文
摘要:题目描述 The only difference between easy and hard versions is constraints. You are given a sequence a a a consisting of n n n positive integers. Let's de
阅读全文
摘要:Eugene likes working with arrays. And today he needs your help in solving one challenging task. An array cc is a subarray of an array bb if cc can be
阅读全文