[Codeforces] Round 792 (Div. 1 + Div. 2) E. MEX vs DIFFRead more
[Codeforces] Round 810 (Div. 1) B. RainRead more
[Codeforces] COMPFEST 14 - Preliminary Online Mirror (Unrated, ICPC Rules, Teams Preferred) F. Field PhotographyRead more
[LeetCode] Number of Divisible Substrings

2950. Number of Divisible Substrings

Each character of the English alphabet has been mapped to a digit as shown below.

img

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 of s.

A substring is a contiguous non-empty sequence of characters within a string.

Read more
[LeetCode] Number of Equal Numbers Blocks

2936. Number of Equal Numbers Blocks

You are given a 0-indexed array of integers, nums. The following property holds for nums:

  • All occurrences of a value are adjacent. In other words, if there are two indices i < j such that nums[i] == nums[j], then for every index k that i < k < j, nums[k] == nums[i].

Since nums is a very large array, you are given an instance of the class BigArray which has the following functions:

  • int at(long long index): Returns the value of nums[i].
  • void size(): Returns nums.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 > 10 is undefined.

Read more
[LeetCode] Minimum Number of Coins for Fruits II

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, where prices[i] denotes the number of coins needed to purchase the ith fruit.

The fruit market has the following offer:

  • If you purchase the ith fruit at prices[i] coins, you can get the next i fruits for free.

Note that even if you can take fruit j for free, you can still purchase it for prices[j] coins to receive a new offer.

Return the minimum number of coins needed to acquire all the fruits.

Read more
[LeetCode] Maximum GCD-Sum of a Subarray

2941. Maximum GCD-Sum of a Subarray

You are given an array of integers nums and an integer k.

The gcd-sum of an array a is calculated as follows:

  • Let s be the sum of all the elements of a.
  • Let g be the greatest common divisor of all the elements of a.
  • The gcd-sum of a is equal to s * g.

Return the maximum gcd-sum of a subarray of nums with at least k elements.

Read more
[LeetCode] Distribute Candies Among Children III

2927. Distribute Candies Among Children III

You are given two positive integers n and limit.

Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.

Read more
[Hacker Earth] Fredo`s CrushRead more
[Hacker Earth] Fredo and his Birthday GiftRead more