[LeetCode] Find the Lexicographically Smallest Valid Sequence

3302. Find the Lexicographically Smallest Valid Sequence

You are given two strings word1 and word2.

A string x is called almost equal to y if you can change at most one character in x to make it identical to y.

A sequence of indices seq is called valid if:

  • The indices are sorted in ascending order.
  • Concatenating the characters at these indices in word1 in the same order results in a string that is almost equal to word2.

Return an array of size word2.length representing the lexicographically smallest valid sequence of indices. If no such sequence of indices exists, return an empty array.

Note that the answer must represent the lexicographically smallest array, not the corresponding string formed by those indices.

Read more
[LeetCode] Maximize the Total Height of Unique Towers

3301. Maximize the Total Height of Unique Towers

You are given an array maximumHeight, where maximumHeight[i] denotes the maximum height the ith tower can be assigned.

Your task is to assign a height to each tower so that:

  1. The height of the ith tower is a positive integer and does not exceed maximumHeight[i].
  2. No two towers have the same height.

Return the maximum possible total sum of the tower heights. If it’s not possible to assign heights, return -1.

Read more
[LeetCode] Minimum Element After Replacement With Digit Sum

3300. Minimum Element After Replacement With Digit Sum

You are given an integer array nums.

You replace each element in nums with the sum of its digits.

Return the minimum element in nums after all replacements.

Read more
[LeetCode] Sum of Consecutive Subsequences

3299. Sum of Consecutive Subsequences

We call an array arr of length n consecutive if one of the following holds:

  • arr[i] - arr[i - 1] == 1 for all 1 <= i < n.
  • arr[i] - arr[i - 1] == -1 for all 1 <= i < n.

The value of an array is the sum of its elements.

For example, [3, 4, 5] is a consecutive array of value 12 and [9, 8] is another of value 17. While [3, 4, 3] and [8, 6] are not consecutive.

Given an array of integers nums, return the sum of the values of all consecutive non-empty subsequences.

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

Note that an array of length 1 is also considered consecutive.

Read more
[Codeforces] Round 961 (Div. 2) B2. Bouquet (Hard Version)Read more
[Codeforces] Round 959 sponsored by NEAR (Div. 1 + Div. 2) D. Funny GameRead more
[Codeforces] Round 959 sponsored by NEAR (Div. 1 + Div. 2) C. Hungry GamesRead more
[Codeforces] Round 957 (Div. 3) F. Valuable CardsRead more
[Codeforces] Pinely Round 4 (Div. 1 + Div. 2) E. Coloring GameRead more
[Codeforces] Round 957 (Div. 3) E. Novice`s MistakeRead more