2950. Number of Divisible Substrings
Each character of the English alphabet has been mapped to a digit as shown below.
A string is divisible if the sum of the mapped values of its characters is divisible by its length.
Given a string
s, return the number of divisible substrings ofs.A substring is a contiguous non-empty sequence of characters within a string.
2936. Number of Equal Numbers Blocks
You are given a 0-indexed array of integers,
nums. The following property holds fornums:
- All occurrences of a value are adjacent. In other words, if there are two indices
i < jsuch thatnums[i] == nums[j], then for every indexkthati < k < j,nums[k] == nums[i].Since
numsis a very large array, you are given an instance of the classBigArraywhich has the following functions:
int at(long long index): Returns the value ofnums[i].void size(): Returnsnums.length.Let’s partition the array into maximal blocks such that each block contains equal values. Return the number of these blocks.
Note that if you want to test your solution using a custom test, behavior for tests with
nums.length > 10is undefined.
2969. Minimum Number of Coins for Fruits II
You are at a fruit market with different types of exotic fruits on display.
You are given a 1-indexed array
prices, whereprices[i]denotes the number of coins needed to purchase theithfruit.The fruit market has the following offer:
- If you purchase the
ithfruit atprices[i]coins, you can get the nextifruits for free.Note that even if you can take fruit
jfor free, you can still purchase it forprices[j]coins to receive a new offer.Return the minimum number of coins needed to acquire all the fruits.
2941. Maximum GCD-Sum of a Subarray
You are given an array of integers
numsand an integerk.The gcd-sum of an array
ais calculated as follows:
- Let
sbe the sum of all the elements ofa.- Let
gbe the greatest common divisor of all the elements ofa.- The gcd-sum of
ais equal tos * g.Return the maximum gcd-sum of a subarray of
numswith at leastkelements.
2927. Distribute Candies Among Children III
You are given two positive integers
nandlimit.Return the total number of ways to distribute
ncandies among3children such that no child gets more thanlimitcandies.