All Posts

Leetcode 2420: Find All Good Indices

Given an integer array nums of size n and a positive integer k, find all good indices in the array. An index i is considered good if: The k elements just before it are in non-increasing order, and the k elements just after it are in non-decreasing order. Return a list of all good indices in increasing order.

Leetcode 2424: Longest Uploaded Prefix

You are given a stream of n distinct videos, each represented by a unique number from 1 to n. You need to design a data structure that tracks the longest prefix of uploaded videos at any point in time. A prefix is considered uploaded if all videos from 1 to i (inclusive) have been uploaded to the server.

Leetcode 2425: Bitwise XOR of All Pairings

You are given two arrays, nums1 and nums2, each consisting of non-negative integers. You need to calculate the XOR of all possible pairings between the integers in nums1 and nums2. The result should be the XOR of all the numbers from this new array formed by XORing every integer in nums1 with every integer in nums2.

Leetcode 2428: Maximum Sum of an Hourglass

You are given a matrix of integers. An hourglass is defined as a pattern of elements in the matrix where the middle element is surrounded by 3 elements above it and 3 elements below it, forming the shape of an hourglass. Your task is to find the maximum sum of all hourglasses that can be formed within the matrix.

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 2433: Find The Original Array of Prefix Xor

You are given an integer array pref of size n. Your task is to find and return an array arr of size n that satisfies the following condition: each element pref[i] equals the XOR of all elements from arr[0] to arr[i]. In other words, pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i] where ^ denotes the bitwise XOR operation. It is guaranteed that there is a unique solution.