3298. Count Substrings That Can Be Rearranged to Contain a String II
You are given two strings
word1
andword2
.A string
x
is called valid ifx
can be rearranged to haveword2
as a prefix.Return the total number of valid substrings of
word1
.Note that the memory limits in this problem are smaller than usual, so you must implement a solution with a linear runtime complexity.
3297. Count Substrings That Can Be Rearranged to Contain a String I
You are given two strings
word1
andword2
.A string
x
is called valid ifx
can be rearranged to haveword2
as a prefix.Return the total number of valid substrings of
word1
.
3296. Minimum Number of Seconds to Make Mountain Height Zero
You are given an integer
mountainHeight
denoting the height of a mountain.
You are also given an integer arrayworkerTimes
representing the work time of workers in seconds.
The workers work simultaneously to reduce the height of the mountain. For workeri
:
To decrease the mountain’s height by
x
, it takesworkerTimes[i] + workerTimes[i] * 2 + ... + workerTimes[i] * x
seconds. For example:To reduce the height of the mountain by 1, it takes
workerTimes[i]
seconds.- To reduce the height of the mountain by 2, it takes
workerTimes[i] + workerTimes[i] * 2
seconds, and so on.Return an integer representing the minimum number of seconds required for the workers to make the height of the mountain 0.
You are given an array of strings
message
and an array of stringsbannedWords
.An array of words is considered spam if there are at least two words in it that exactly match any word in
bannedWords
.Return
true
if the arraymessage
is spam, andfalse
otherwise.