[Codeforces] Round 667 (Div. 3) F. Subsequences of Length TwoRead more
[Codeforces] Technocup 2021 - Elimination Round 3 D. Grime ZooRead more
[Codeforces] Technocup 2021 - Elimination Round 1 E. Solo mid OracleRead more
[Codeforces] Educational Round 95 (Rated for Div. 2) D. Trash ProblemRead more
[LeetCode] Maximum Number of Removal Queries That Can Be Processed I

3018. Maximum Number of Removal Queries That Can Be Processed I

You are given a 0-indexed array nums and a 0-indexed array queries.

You can do the following operation at the beginning at most once:

  • Replace nums with a subsequence of nums.

We start processing queries in the given order; for each query, we do the following:

  • If the first and the last element of nums is less than queries[i], the processing of queries ends.
  • Otherwise, we choose either the first or the last element of nums if it is greater than or equal to queries[i], and we remove the chosen element from nums.

Return the maximum number of queries that can be processed by doing the operation optimally.

Read more
[LeetCode] Maximum Number of Intersections on the Chart

3009. Maximum Number of Intersections on the Chart

There is a line chart consisting of n``y. The kth point has coordinates (k, y[k]). There are no horizontal lines; that is, no two consecutive points have the same y-coordinate.

We can draw an infinitely long horizontal line. Return the maximum number of points of intersection of the line with the chart.

Read more
[LeetCode] Number of Self-Divisible Permutations

2992. Number of Self-Divisible Permutations

Given an integer n, return the number of permutations of the 1-indexed array nums = [1, 2, ..., n], such that it’s self-divisible.

A 1-indexed array a of length n is self-divisible if for every 1 <= i <= n, gcd(a[i], i) == 1.

A permutation of an array is a rearrangement of the elements of that array, for example here are all of the permutations of the array [1, 2, 3]:

  • [1, 2, 3]
  • [1, 3, 2]
  • [2, 1, 3]
  • [2, 3, 1]
  • [3, 1, 2]
  • [3, 2, 1]
Read more
[LeetCode] Most Expensive Item That Can Not Be Bought

2979. Most Expensive Item That Can Not Be Bought

You are given two distinct prime numbers primeOne and primeTwo.

Alice and Bob are visiting a market. The market has an infinite number of items, for any positive integer x there exists an item whose price is x. Alice wants to buy some items from the market to gift to Bob. She has an infinite number of coins in the denomination primeOne and primeTwo. She wants to know the most expensive item she can not buy to gift to Bob.

Return the price of the most expensive item which Alice can not gift to Bob.

Read more
[LeetCode] Number of Divisible Triplet Sums

2964. Number of Divisible Triplet Sums

Given a 0-indexed integer array nums and an integer d, return the number of triplets (i, j, k) such that i < j < k and (nums[i] + nums[j] + nums[k]) % d == 0.

Read more
[Hacker Earth] Costly Phone NumberRead more