题意:给出只含有两种字符的字符串以及一个次数限制k,问最多修改k个位置(T->F/F->T),最大的连续的字符串的长度是多少
思路:双指针/滑动窗口
假如说我们要找修改后连续的T最长的长度,我们可以{
枚举右端点,并统计当前不等于’T’的字符串的个数,并且统计数量,记为c n t cntcnt
如果说左区间到右区间的c n t cntcnt 是否 小于等于 k{
(1)如果说数量上大于k了,就只能让左端点向右,并记录cnt的减小情况,直到cnt <= k
}
过程中统计区间长度并记录最大值
}
二叉树简单遍历
将访问的序列存入 vector,对于每一层交替从左向右从右向左我们可以设置一个变量flag来决定方向
用 pre 表示上一层的节点数量,用 cnt 求得上本层的节点数量,在遍历的时候遇到一个点就将 pre−1,如果说 pre 为0了,那么就说明上一层的节点已经访问完毕,然后将在该过程中访问得到 val 的 vector 集合存入答案,根据 flag 的值进行判断是否需要逆置
前缀和思想
用数组 l[ ]表示前面有多少个数满足 a[i−1]>=a[i]
用数组 r[] 表示前面有多少个数满足 a[i]<=a[i+1]
O(n)遍历之后得到 l[] , r[]
然后O(n)找满足l [ i ] > = t i m e & & r [ i ] > = t i m e 的下标存入 vector 并返回
给你 k 枚相同的鸡蛋,并可以使用一栋从第 1 层到第 n 层共有 n 层楼的建筑。
已知存在楼层 f ,满足 0 <= f <= n ,任何从 高于 f 的楼层落下的鸡蛋都会碎,从 f 楼层或比它低的楼层落下的鸡蛋都不会破。
每次操作,你可以取一枚没有碎的鸡蛋并把它从任一楼层 x 扔下(满足 1 <= x <= n)。如果鸡蛋碎了,你就不能再次使用它。如果某枚鸡蛋扔下后没有摔碎,则可以在之后的操作中 重复使用 这枚鸡蛋。
请你计算并返回要确定 f 确切的值 的 最小操作次数 是多少?
Evlampiy was gifted a rooted tree. The vertices of the tree are numbered from 1 to n. Each of its vertices also has an integer ai written on it. For each vertex i, Evlampiy calculated ci — the number of vertices j in the subtree of vertex i, such that a j < a i
Description
Katu Puzzle is presented as a directed graph G ( V , E ) with each edge e ( a , b ) labeled by a boolean operator op (oneofAND,OR,XOR) and an integer c ( 0 ≤ c ≤ 1 ) . One Katu is solvable if one can find each vertex Vi a value X i ( 0 ≤ X i ≤ 1 )
题目描述
Åke has heard that there may be some suspicious 5G radiation in his city. To test this, he uses the antenna on his roof to measure the 5G level each day. However, he does not know how he should analyze the data.
题目描述
This year, there have been unusually many UFO sightings reported. Nobody knows if they are caused by optical illusions, weather phenomena, or secret technology being tested by foreign powers (terrestrial or not). UFO enthusiasts across the world rejoice, and speculations run wild.
题目描述
Xiao Ming recently designs a little game, in front of player there are N small hillsides put in order, now Xiao Ming wants to increase some hillsides to block the player, so he prepared another M hillsides, but he does not hope it will be too difficult,
Description
A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list of schools to which it distributes software (the “receiving schools”).
Description
Recently, Zayin became obsessed with a tower defense game called Arknights. The most special level is the 5th level of chapter 4: Don’t panic. The most special thing about this level is that an enemy will continue taking radioactive damage after passing through the Active Originiums.
Description
Little Johnny has got a new car. He decided to drive around the town to visit his friends. Johnny wanted to visit all his friends, but there was many of them. In each street he had one friend. He started thinking how to make his trip as short as possible.
Description
Bessie’s been appointed the new watch-cow for the farm. Every night, it’s her job to walk across the farm and make sure that no evildoers are doing any evil. She begins at the barn, makes her patrol, and then returns to the barn when she’s done.
题目描述
Consider a directed graph with N (1 <= N <= 1000) vertices and M (0 <=M <= 20000) edges. The edges are numbered from 1 to M and the vertices are numbered from 1 to N. Now I will make ONE edge bidirectional, and you are to tell me the number of vertices of the largest strong connected components
题目描述
A network administrator manages a large network. The network consists of N computers and M links between pairs of computers. Any pair of computers are connected directly or indirectly by successive links, so data can be transformed between any two computers.
Problem Description
Caocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi. But he wouldn’t give up. Caocao’s army still was not good at water battles, so he came up with another idea. He built many islands in the Changjiang river,
题意
给定一个n ∗ m 的方格,在这个方格中有一些点被标记为′ . ′ 说明这个点是没有障碍的,而′ X ′ 代表这个点是有障碍的,不能通过这个点,对于每个点,只能向上或者是向左走。如所说有的′ . ′ 点不能走出去,那么这样的′ . ′ 点就不是e x i t a b l e exitable
问题是:给定一个矩阵里面所有的 exitable点,如果给出的矩阵能够唯一确定,就是YES,否则输出 NO
所以问题就变成了给定的矩阵范围中有没有是′ . ′但是不能够 exitable的点,如果有就无法唯一确定(YES),反之就可以唯一确定(NO)
数据范围太大,可以开 vector 来模拟二维数
Description
New labyrinth attraction is open in New Lostland amusement park. The labyrinth consists of n rooms connected by m passages. Each passage is colored into some color ci .
Description
Every (positive) rational number can be expressed as a ratio of two (positive) integers. However, in decimal form, rational numbers often have an infifinitely repeating pattern, e.g., 1/7 = 0.142857142857142857…