All Posts

Leetcode 2434: Using a Robot to Print the Lexicographically Smallest String

You are given a string s and a robot that starts with an empty string t. The robot can perform two operations: one, it can remove the first character of string s and append it to t, and two, it can remove the last character of string t and write it down. The goal is to return the lexicographically smallest string that can be written on paper using these operations.

Leetcode 2438: Range Product Queries of Powers

Given a positive integer n, you need to construct an array called powers that contains the minimum number of powers of 2 that sum up to n. The array powers should be sorted in non-decreasing order. You are also given a set of queries where each query asks for the product of the powers in the powers array between indices left and right (both inclusive). For each query, return the product modulo 10^9 + 7.

Leetcode 2439: Minimize Maximum of Array

You are given a 0-indexed array nums of length n, where each element represents the number of items in a container. In one operation, you can pick an index i such that 1 <= i < n and nums[i] > 0, and move one item from nums[i] to nums[i-1]. Your goal is to minimize the maximum value in the array nums after performing any number of operations.

Leetcode 2442: Count Number of Distinct Integers After Reverse Operations

You are given an array nums consisting of positive integers. For each number in the array, you need to reverse its digits and append the reversed number to the end of the array. After performing this operation for all numbers, return the number of distinct integers in the resulting array.

Leetcode 2443: Sum of Number and Its Reverse

Given a non-negative integer num, determine if num can be expressed as the sum of a non-negative integer and its reverse. If so, return true, otherwise return false.

Leetcode 2447: Number of Subarrays With GCD Equal to K

Given an integer array nums and an integer k, return the number of subarrays in which the greatest common divisor (GCD) of all the elements is exactly k. A subarray is a contiguous non-empty sequence of elements within the array.