All Posts

Leetcode 2825: Make String a Subsequence Using Cyclic Increments

Given two strings, str1 and str2, you can perform an operation on str1 where you select a set of indices and increment the characters at those indices cyclically. The task is to check if it is possible to make str2 a subsequence of str1 by performing the operation at most once.

Leetcode 2856: Minimum Array Length After Pair Removals

You are given a non-decreasing sorted integer array. Perform operations to remove pairs of elements where nums[i] < nums[j] and return the minimum length of the array after the operations.

Leetcode 2903: Find Indices With Index and Value Difference I

You are given a 0-indexed array of integers nums of length n, along with two integers, indexDifference and valueDifference. Your task is to find two indices i and j such that the difference between the indices is greater than or equal to indexDifference, and the absolute difference between the values at the indices is greater than or equal to valueDifference. Return the indices [i, j] if such a pair exists, otherwise return [-1, -1].

Leetcode 2905: Find Indices With Index and Value Difference II

You are given an integer array nums of size n, an integer indexDifference, and an integer valueDifference. Your task is to find two indices i and j that satisfy the following conditions:

  • abs(i - j) >= indexDifference,
  • abs(nums[i] - nums[j]) >= valueDifference.

Return the indices [i, j] if such a pair exists, or [-1, -1] if no such pair exists. If there are multiple pairs, any valid pair is acceptable.

Leetcode 2938: Separate Black and White Balls

You are given a binary string s of length n, where each character represents a ball: ‘1’ for black and ‘0’ for white. The goal is to arrange the balls such that all the white balls are on the left side and all the black balls are on the right side, by swapping two adjacent balls in each step. You need to find the minimum number of adjacent swaps required to achieve this arrangement.