All Posts

Leetcode 2961: Double Modular Exponentiation

Given a 2D array variables where each element is a list of integers [a, b, c, m], and an integer target, find the indices where the formula (a * b % 10) ^ c % m equals the target. Return a list of these indices.

Leetcode 3100: Water Bottles II

You are given two integers: numBottles, representing the number of full water bottles you initially have, and numExchange, representing the number of empty bottles required to exchange for a full bottle. In one operation, you can drink any number of full water bottles, turning them into empty bottles, or exchange numExchange empty bottles for one full bottle, with numExchange increasing by 1 after each exchange. Return the maximum number of water bottles you can drink.

Leetcode 3168: Minimum Number of Chairs in a Waiting Room

You are given a string s representing a sequence of events where each character is either ‘E’ (a person enters the waiting room) or ‘L’ (a person leaves the waiting room). The waiting room starts empty. Simulate the events and determine the minimum number of chairs required to ensure there is always a chair available for every person who enters the room.

Leetcode 3178: Find the Child Who Has the Ball After K Seconds

You are given two positive integers, n and k. There are n children numbered from 0 to n - 1, standing in a queue from left to right. Initially, child 0 holds a ball and the direction of passing the ball is towards the right. After each second, the child holding the ball passes it to the next child in the queue. If the ball reaches the first or last child, the direction of passing the ball reverses. You need to determine which child will have the ball after k seconds.

Leetcode 3179: Find the N-th Value After K Seconds

You are given two integers, n and k. Initially, you have an array a of size n, where each element is initialized to 1. After each second, every element in the array is updated to be the sum of all preceding elements plus the element itself. The process repeats for k seconds. You need to return the value of the last element of the array, a[n - 1], after k seconds. Since the result may be very large, return it modulo (10^9 + 7).