All Posts

Leetcode 2389: Longest Subsequence With Limited Sum

You are given an integer array nums of length n and an integer array queries of length m. For each query, return the maximum size of a subsequence that can be selected from nums such that the sum of its elements is less than or equal to the query value. A subsequence is derived by deleting some or no elements from the array while keeping the relative order intact.

Leetcode 2405: Optimal Partition of String

You are given a string s. Your task is to partition this string into the fewest number of substrings such that no character appears more than once in each substring. Each character must belong to exactly one substring in the partition.

Leetcode 2406: Divide Intervals Into Minimum Number of Groups

You are given a 2D array of intervals, where each interval is represented as a pair of integers [left, right], denoting an inclusive range. Your task is to divide these intervals into the minimum number of groups such that no two intervals within the same group overlap. Two intervals overlap if there is at least one common number between them.

Leetcode 2410: Maximum Matching of Players With Trainers

You are given two arrays: ‘players’ and ’trainers’. The array ‘players’ represents the abilities of different players, and the array ’trainers’ represents the training capacities of various trainers. A player can be matched with a trainer if the player’s ability is less than or equal to the trainer’s capacity. The goal is to find the maximum number of valid matchings between players and trainers such that each player is matched with at most one trainer and vice versa.

Leetcode 2429: Minimize XOR

You are given two positive integers, num1 and num2. Your task is to find a positive integer x such that: 1. x has the same number of set bits (1’s in binary representation) as num2, and 2. The value of x XOR num1 is minimized. The XOR operation is performed bitwise. Your goal is to return the integer x.

Leetcode 2434: Using a Robot to Print the Lexicographically Smallest String

You are given a string s and a robot that starts with an empty string t. The robot can perform two operations: one, it can remove the first character of string s and append it to t, and two, it can remove the last character of string t and write it down. The goal is to return the lexicographically smallest string that can be written on paper using these operations.