All Posts

Leetcode 1253: Reconstruct a 2-Row Binary Matrix

You are given a binary matrix with 2 rows and n columns, where each element is either 0 or 1. The sum of elements in the 0-th (upper) row is given by upper, the sum of elements in the 1-st (lower) row is given by lower, and the column-wise sum is given by colsum. Your task is to reconstruct the matrix based on these sums. If reconstruction is not possible, return an empty matrix.

Leetcode 1262: Greatest Sum Divisible by Three

Given an array of integers, find the maximum sum of any subsequence where the sum is divisible by 3.

Leetcode 1282: Group the People Given the Group Size They Belong To

Given an array where each element represents the required size of the group for each person, group the people accordingly and return the groups. Each person must be in exactly one group.

Leetcode 1296: Divide Array in Sets of K Consecutive Numbers

Given an array of integers nums and a positive integer k, check if it is possible to divide the array into sets of k consecutive numbers.

Leetcode 1328: Break a Palindrome

Given a string palindrome that is a palindrome, you need to replace exactly one character with any lowercase English letter such that the resulting string is no longer a palindrome. The resulting string should be the lexicographically smallest string possible. If it is not possible to change the string to make it non-palindromic, return an empty string.

Leetcode 1338: Reduce Array Size to The Half

You are given an integer array arr. You can choose a set of integers and remove all occurrences of these integers. Your task is to return the minimum size of the set such that at least half of the integers of the array are removed.