All Posts

Leetcode 1052: Grumpy Bookstore Owner

A bookstore owner has a store open for ’n’ minutes. During each minute, a certain number of customers enter the store, but the owner may be grumpy and fail to satisfy some customers. The grumpy behavior of the owner is given as a binary array, where 1 means the owner is grumpy and 0 means they are not. The owner has a special technique to remain calm for a specified number of consecutive minutes, but it can only be used once. The goal is to find the maximum number of customers who can be satisfied throughout the day by using this technique.

Leetcode 1053: Previous Permutation With One Swap

Given an array of positive integers, return the lexicographically largest permutation that is smaller than the given array. This can be done by swapping exactly two elements. If no such swap is possible (i.e., the array is already the smallest permutation), return the same array.

Leetcode 1054: Distant Barcodes

You are given an array of barcodes where each element represents a barcode. Your task is to rearrange the barcodes such that no two adjacent barcodes are the same. It is guaranteed that a solution exists, and you may return any valid rearrangement.

Leetcode 1061: Lexicographically Smallest Equivalent String

You are given two strings, s1 and s2, which contain the same length, and a third string baseStr. Each pair of corresponding characters from s1 and s2 represent equivalent characters. Your task is to return the lexicographically smallest equivalent string for baseStr, where each character is replaced with its lexicographically smallest equivalent based on the equivalency information from s1 and s2.

Leetcode 1072: Flip Columns For Maximum Number of Equal Rows

You are given an m x n binary matrix. You can choose any number of columns in the matrix and flip every cell in that column (i.e., change the value of the cell from 0 to 1 or vice versa). Your task is to find the maximum number of rows that can be made equal after performing a number of column flips.

Leetcode 1073: Adding Two Negabinary Numbers

You are given two numbers represented in base -2. Each number is given as an array of binary digits (0s and 1s), where the most significant bit is at the beginning of the array. Your task is to add these two numbers together and return the result in the same format, as an array of 0s and 1s in base -2, without leading zeros.