All Posts

Leetcode 1855: Maximum Distance Between a Pair of Values

You are given two non-increasing 0-indexed integer arrays nums1 and nums2. A pair of indices (i, j) is valid if both i <= j and nums1[i] <= nums2[j]. The distance of the pair is j - i. You need to return the maximum distance of any valid pair (i, j). If there are no valid pairs, return 0.

Leetcode 1861: Rotating the Box

You are given an m x n matrix of characters box, where each cell is a stone (#), a stationary obstacle (*), or an empty space (.). After rotating the box 90 degrees clockwise, gravity will cause stones to fall down until they land on an obstacle, another stone, or the bottom. Return the updated matrix after the stones have fallen.

Leetcode 1877: Minimize Maximum Pair Sum in Array

Given an array nums of even length n, your task is to pair up the elements of the array into n / 2 pairs such that the maximum pair sum is minimized. A pair sum is defined as the sum of two elements in a pair. The goal is to minimize the largest of these pair sums.

Leetcode 1898: Maximum Number of Removable Characters

You are given two strings s and p, where p is a subsequence of s. You are also given an array removable containing distinct indices of s. Your task is to determine the maximum number of indices you can remove from s such that p is still a subsequence of the remaining string.

Leetcode 1961: Check If String Is a Prefix of Array

You are given a string s and an array of strings words. Determine if the string s can be formed by concatenating the first k strings from the array words, for some value of k, where 1 <= k <= words.length. Return true if s is a prefix of words, or false otherwise.

Leetcode 1963: Minimum Number of Swaps to Make the String Balanced

You are given a string s of even length n. The string contains exactly n/2 opening brackets [ and n/2 closing brackets ]. A string is called balanced if for every opening bracket there exists a corresponding closing bracket, with each closing bracket having a matching opening bracket before it. Your task is to return the minimum number of swaps needed to make the string balanced.