All Posts

Leetcode 1720: Decode XORed Array

You are given an encoded array of length n - 1, where each element encoded[i] represents the XOR of two consecutive elements in the original array arr, i.e., encoded[i] = arr[i] XOR arr[i + 1]. You are also given the first element of the original array arr[0]. Your task is to decode the array and return the original array arr.

Leetcode 1722: Minimize Hamming Distance After Swap Operations

You are given two integer arrays, source and target, both of length n, and an array allowedSwaps containing pairs of indices where swapping is allowed. You can perform multiple swaps between the specified pairs to minimize the Hamming distance between source and target. The Hamming distance is the number of indices where the elements of source and target differ.

Leetcode 1725: Number Of Rectangles That Can Form The Largest Square

You are given an array rectangles where each element rectangles[i] = [li, wi] represents a rectangle with length li and width wi. You can cut a square from the rectangle as long as the side of the square is less than or equal to both the length and width of the rectangle. Your task is to find the largest possible square that can be cut from any of the given rectangles, and then return how many rectangles can produce that largest square.

Leetcode 1726: Tuple with Same Product

You are given an array of distinct positive integers nums. Your task is to count how many tuples (a, b, c, d) exist such that the product of a * b equals the product of c * d, where a, b, c, d are distinct elements of nums and a != b != c != d.

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 1732: Find the Highest Altitude

A biker is going on a road trip, where the trip consists of several points with different altitudes. The biker starts at point 0, which has an altitude of 0. You are given an array of integers gain, where each value represents the change in altitude between two consecutive points. Your task is to find the highest altitude the biker reaches during the trip.