2264. Largest 3-Same-Digit Number in String
You are given a string
numrepresenting a large integer. An integer is good if it meets the following conditions:
- It is a substring of
numwith length3.- It consists of only one unique digit.
Return the maximum good integer as a string or an empty string
""if no such integer exists.Note:
- A substring is a contiguous sequence of characters within a string.
- There may be leading zeroes in
numor a good integer.
2954. Count the Number of Infection Sequences
You are given an integer
nand a 0-indexed integer arraysickwhich is sorted in increasing order.There are
nchildren standing in a queue with positions0ton - 1assigned to them. The arraysickcontains the positions of the children who are infected with an infectious disease. An infected child at positionican spread the disease to either of its immediate neighboring children at positionsi - 1andi + 1if they exist and are currently not infected. At most one child who was previously not infected can get infected with the disease in one second.It can be shown that after a finite number of seconds, all the children in the queue will get infected with the disease. An infection sequence is the sequential order of positions in which all of the non-infected children get infected with the disease. Return the total number of possible infection sequences.
Since the answer may be large, return it modulo
109 + 7.Note that an infection sequence does not contain positions of children who were already infected with the disease in the beginning.
2953. Count Complete Substrings
You are given a string
wordand an integerk.A substring
sofwordis complete if:
- Each character in
soccurs exactlyktimes.- The difference between two adjacent characters is at most
2. That is, for any two adjacent charactersc1andc2ins, the absolute difference in their positions in the alphabet is at most2.Return the number of complete substrings of
word.A substring is a non-empty contiguous sequence of characters in a string.
2952. Minimum Number of Coins to be Added
You are given a 0-indexed integer array
coins, representing the values of the coins available, and an integertarget.An integer
xis obtainable if there exists a subsequence ofcoinsthat sums tox.Return the minimum number of coins of any value that need to be added to the array so that every integer in the range
[1, target]is obtainable.A subsequence of an array is a new non-empty array that is formed from the original array by deleting some (possibly none) of the elements without disturbing the relative positions of the remaining elements.
You are given a 0-indexed array
mountain. Your task is to find all the peaks in themountainarray.Return an array that consists of indices of peaks in the given array in any order.
Notes:
- A peak is defined as an element that is strictly greater than its neighboring elements.
- The first and last elements of the array are not a peak.