[Hacker Earth] The MarketRead more
[Hacker Earth] Killjee and base XRead more
[Codeforces] Round 150 (Div. 1) B. HydraRead more
[Codeforces] CROC-MBTU 2012, Elimination Round (ACM-ICPC) F. Log Stream AnalysisRead more
[Codeforces] Round 152 (Div. 2) C. Robo-FootballerRead more
[Codeforces] CROC-MBTU 2012, Final Round (Online version, Div. 2) E. Mad JoeRead more
[Codeforces] Round 153 (Div. 1) C. Number TransformationRead more
[LeetCode] Maximum Product of Two Elements in an Array

1464. Maximum Product of Two Elements in an Array

Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1).

Read more
[LeetCode] Number of Ways to Reach Destination in the Grid

2912. Number of Ways to Reach Destination in the Grid

You are given two integers n and m which represent the size of a 1-indexed grid. You are also given an integer k, a 1-indexed integer array source and a 1-indexed integer array dest, where source and dest are in the form [x, y] representing a cell on the given grid.

You can move through the grid in the following way:

  • You can go from cell [x1, y1] to cell [x2, y2] if either x1 == x2 or y1 == y2.
  • Note that you can’t move to the cell you are already in e.g. x1 == x2 and y1 == y2.

Return the number of ways you can reach dest from source by moving through the grid exactly k times.

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

Read more
[LeetCode] Maximum Profitable Triplets With Increasing Prices II

2921. Maximum Profitable Triplets With Increasing Prices II

Given the 0-indexed arrays prices and profits of length n. There are n items in an store where the ith item has a price of prices[i] and a profit of profits[i].

We have to pick three items with the following condition:

  • prices[i] < prices[j] < prices[k] where i < j < k.

If we pick items with indices i, j and k satisfying the above condition, the profit would be profits[i] + profits[j] + profits[k].

Return the maximum profit we can get, and -1 if it’s not possible to pick three items with the given condition.

Read more