[AtCoder] D - Road to MillionaireRead more
[Codeforces] Experimental Educational Round: VolBIT Formulas Blitz L. Cracking the CodeRead more
[Codeforces] Educational Round 9 B. Alice, Bob, Two TeamsRead more
[Codeforces] VK Cup 2016 - Qualification Round 1 C. Promocodes with MistakesRead more
[Codeforces] VK Cup 2016 - Round 2 B. Little Artem and MatrixRead more
[Codeforces] Round #345 (Div. 1) A. WatchmenRead more
[LeetCode] Minimum Swaps to Make Strings Equal

1247. Minimum Swaps to Make Strings Equal

You are given two strings s1 and s2 of equal length consisting of letters “x” and “y” only. Your task is to make these two strings equal to each other. You can swap any two characters that belong to different strings, which means: swap s1[i] and s2[j].

Return the minimum number of swaps required to make s1 and s2 equal, or return -1 if it is impossible to do so.

Read more
[LeetCode] Minimum Adjacent Swaps to Make a Valid Array

2340. Minimum Adjacent Swaps to Make a Valid Array

You are given a 0-indexed integer array nums.

Swaps of adjacent elements are able to be performed on nums.

A valid array meets the following conditions:

  • The largest element (any of the largest elements if there are multiple) is at the rightmost position in the array.
  • The smallest element (any of the smallest elements if there are multiple) is at the leftmost position in the array.

Return the minimum swaps required to make nums a valid array.

Read more
[LeetCode] Max Sum of a Pair With Equal Sum of Digits

2342. Max Sum of a Pair With Equal Sum of Digits

You are given a 0-indexed array nums consisting of positive integers. You can choose two indices i and j, such that i != j, and the sum of digits of the number nums[i] is equal to that of nums[j].

Return the maximum value of nums[i] + nums[j] that you can obtain over all possible indices i and j that satisfy the conditions.

Read more
[LeetCode] Query Kth Smallest Trimmed Number

2343. Query Kth Smallest Trimmed Number

You are given a 0-indexed array of strings nums, where each string is of equal length and consists of only digits.

You are also given a 0-indexed 2D integer array queries where queries[i] = [ki, trimi]. For each queries[i], you need to:

  • Trim each number in nums to its rightmost trimi digits.
  • Determine the index of the kith smallest trimmed number in nums. If two trimmed numbers are equal, the number with the lower index is considered to be smaller.
  • Reset each number in nums to its original length.

Return an array answer of the same length as queries, where answer[i] is the answer to the ith query.

Note:

  • To trim to the rightmost x digits means to keep removing the leftmost digit, until only x digits remain.
  • Strings in nums may contain leading zeros.
Read more