[LeetCode] Maximum Spending After Buying Items

2930. Number of Strings Which Can Be Rearranged to Contain Substring

You are given a 0-indexed m * n integer matrix values, representing the values of m * n different items in m different shops. Each shop has n items where the jth item in the ith shop has a value of values[i][j]. Additionally, the items in the ith shop are sorted in non-increasing order of value. That is, values[i][j] >= values[i][j + 1] for all 0 <= j < n - 1.

On each day, you would like to buy a single item from one of the shops. Specifically, On the dth day you can:

  • Pick any shop i.
  • Buy the rightmost available item j for the price of values[i][j] * d. That is, find the greatest index j such that item j was never bought before, and buy it for the price of values[i][j] * d.

Note that all items are pairwise different. For example, if you have bought item 0 from shop 1, you can still buy item 0 from any other shop.

Return the maximum amount of money that can be spent on buying all m * n products.

Read more
[LeetCode] Number of Strings Which Can Be Rearranged to Contain Substring

2931. Maximum Spending After Buying Items

You are given an integer n.

A string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s such that the new string contains "leet" as a substring.

For example:

  • The string "lteer" is good because we can rearrange it to form "leetr" .
  • "letl" is not good because we cannot rearrange it to contain "leet" as a substring.

Return the total number of good strings of length n.

Since the answer may be large, return it modulo 109 + 7.

A substring is a contiguous sequence of characters within a string.

Read more
[LeetCode] Distribute Candies Among Children II

2929. Distribute Candies Among Children II

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
[LeetCode] Distribute Candies Among Children I

2928. Distribute Candies Among Children I

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
[AtCoder] D - Grid Ice FloorRead more
[AtCoder] B - Switching TravelRead more
[AtCoder] C - Reversible Card GameRead more
[AtCoder] E - Family and InsuranceRead more
[AtCoder] B - Favorite Game Read more
[Hacker Earth] Intersection of intervalsRead more