Codeforces Round 965 (Div. 2) C. Perform Operations to Maximize Score
3307. Find the K-th Character in String Game II
Alice and Bob are playing a game. Initially, Alice has a string
word = "a".You are given a positive integer
k. You are also given an integer arrayoperations, whereoperations[i]represents the type of theithoperation.Now Bob will ask Alice to perform all operations in sequence:
- If
operations[i] == 0, append a copy ofwordto itself.- If
operations[i] == 1, generate a new string by changing each character inwordto its next character in the English alphabet, and append it to the originalword. For example, performing the operation on"c"generates"cd"and performing the operation on"zb"generates"zbac".Return the value of the
kthcharacter inwordafter performing all the operations.Note that the character
'z'can be changed to'a'in the second type of operation.
3306. Count of Substrings Containing Every Vowel and K Consonants II
You are given a string
wordand a non-negative integerk.Return the total number of substrings of
wordthat contain every vowel ('a','e','i','o', and'u') at least once and exactlykconsonants.
3305. Count of Substrings Containing Every Vowel and K Consonants I
You are given a string
wordand a non-negative integerk.Return the total number of substrings of
wordthat contain every vowel ('a','e','i','o', and'u') at least once and exactlykconsonants.
3304. Find the K-th Character in String Game I
Alice and Bob are playing a game. Initially, Alice has a string
word = "a".You are given a positive integer
k.Now Bob will ask Alice to perform the following operation forever:
- Generate a new string by changing each character in
wordto its next character in the English alphabet, and append it to the originalword.For example, performing the operation on
"c"generates"cd"and performing the operation on"zb"generates"zbac".Return the value of the
kthcharacter inword, after enough operations have been done forwordto have at leastkcharacters.Note that the character
'z'can be changed to'a'in the operation.
3303. Find the Occurrence of First Almost Equal Substring
You are given two strings
sandpattern.A string
xis called almost equal toyif you can change at most one character inxto make it identical toy.Return the smallest starting index of a substring in
sthat is almost equal topattern. If no such index exists, return-1.A substring is a contiguous non-empty sequence of characters within a string.
3302. Find the Lexicographically Smallest Valid Sequence
You are given two strings
word1andword2.A string
xis called almost equal toyif you can change at most one character inxto make it identical toy.A sequence of indices
seqis called valid if:
- The indices are sorted in ascending order.
- Concatenating the characters at these indices in
word1in the same order results in a string that is almost equal toword2.Return an array of size
word2.lengthrepresenting the lexicographically smallest valid sequence of indices. If no such sequence of indices exists, return an empty array.Note that the answer must represent the lexicographically smallest array, not the corresponding string formed by those indices.