All Posts

Leetcode 1727: Largest Submatrix With Rearrangements

You are given a binary matrix with dimensions m x n consisting of 0’s and 1’s. You can rearrange the columns of the matrix in any order. The task is to find the area of the largest submatrix within the matrix where every element is 1 after optimally reordering the columns.

Leetcode 1733: Minimum Number of People to Teach

In a social network consisting of multiple users and their friendships, users can communicate with each other only if they share a common language. You are given a list of languages each user knows and a list of friendships between users. Your task is to teach a single language to some users such that all the users in each friendship can communicate. The goal is to minimize the number of users you need to teach the new language.

Leetcode 1734: Decode XORed Permutation

You are given an array encoded of length n - 1, which represents the XOR of consecutive elements of a permutation of the first n integers. Your task is to decode the encoded array and return the original permutation perm of size n.

Leetcode 1737: Change Minimum Characters to Satisfy One of Three Conditions

You are given two strings, a and b, consisting of lowercase letters. In one operation, you can change any character in either string to any lowercase letter. Your goal is to perform the minimum number of operations to satisfy one of the following three conditions:

  1. Every character in string a is strictly less than every character in string b alphabetically.
  2. Every character in string b is strictly less than every character in string a alphabetically.
  3. Both a and b consist of only one distinct character.

Return the minimum number of operations needed to achieve one of these conditions.

Leetcode 1738: Find Kth Largest XOR Coordinate Value

You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k. The value of coordinate (a, b) in the matrix is the XOR of all the values from matrix[0][0] to matrix[a][b] (inclusive), where 0 <= a < m and 0 <= b < n (0-indexed). Your task is to find the kth largest value (1-indexed) among all the XOR values of matrix coordinates.

Leetcode 1743: Restore the Array From Adjacent Pairs

You are given an integer array nums with unique elements, but you have forgotten it. However, you do remember every pair of adjacent elements in nums. You are given a 2D integer array adjacentPairs where each adjacentPairs[i] = [ui, vi] indicates that the elements ui and vi are adjacent in nums. Your task is to reconstruct the original array nums using these adjacent pairs. There could be multiple valid solutions, so return any one of them.