All Posts

Leetcode 2332: The Latest Time to Catch a Bus

You are given two arrays representing bus departure times and passenger arrival times, along with the maximum capacity of each bus. The task is to determine the latest time you may arrive at the bus station to catch a bus. You cannot arrive at the same time as another passenger.

Leetcode 2333: Minimum Sum of Squared Difference

You are given two integer arrays, nums1 and nums2, each of length n. You are also given two integers k1 and k2. Modify any element of nums1 or nums2 at most k1 or k2 times, respectively, to minimize the sum of squared differences between the two arrays.

Leetcode 2336: Smallest Number in Infinite Set

You have a set containing all positive integers starting from 1. You need to implement a class SmallestInfiniteSet that has the following methods:

  • SmallestInfiniteSet() Initializes the set to contain all positive integers starting from 1.
  • popSmallest() Removes and returns the smallest integer in the set.
  • addBack(int num) Adds a positive integer num back into the set, if it’s not already present in the set.

Leetcode 2337: Move Pieces to Obtain a String

You are given two strings start and target, each consisting of the characters 'L', 'R', and '_'. The goal is to check if it is possible to transform the string start into target by moving the ‘L’ and ‘R’ characters. ‘L’ can only move to the left and ‘R’ can only move to the right. A blank space can be occupied by either ‘L’ or ‘R’.

Leetcode 2342: Max Sum of a Pair With Equal Sum of Digits

You are given an array nums of positive integers. You need to find two indices i and j such that i != j, and the sum of digits of the numbers nums[i] and nums[j] is the same. Return the maximum sum of nums[i] + nums[j] that you can obtain over all valid pairs of indices. If no such pair exists, return -1.

Leetcode 2343: Query Kth Smallest Trimmed Number

You are given a list nums where each string contains digits of the same length. Additionally, you are provided a list of queries, where each query is represented by two integers [ki, trimi]. For each query, trim each number in nums to its rightmost trimi digits, then find the index of the kith smallest trimmed number. If two numbers are identical after trimming, the one with the lower index is considered smaller. Reset the numbers in nums for the next query.