All Posts
Leetcode 1700: Number of Students Unable to Eat Lunch
In a school cafeteria, sandwiches are placed in a stack and students queue up to get one. Each student has a preference for the type of sandwich, and they either take the sandwich from the stack or move to the back of the queue if the sandwich is not to their liking. The goal is to determine how many students are unable to get a sandwich.
Leetcode 1701: Average Waiting Time
A restaurant with a single chef serves customers. Each customer arrives at a specific time and waits for the chef to prepare their order. The chef can only serve one customer at a time and prepares orders in the order they were received. The goal is to calculate the average waiting time of all customers. The waiting time of a customer is the time between their arrival and when they receive their order.
Leetcode 1705: Maximum Number of Eaten Apples
You have a special apple tree that grows apples for ’n’ days. On each day ‘i’, the tree grows ‘apples[i]’ apples, which rot after ‘days[i]’ days. That means, apples grown on day ‘i’ will rot after ‘i + days[i]’. You can eat at most one apple per day, and you can continue eating after the first ’n’ days. You want to know the maximum number of apples you can eat.
Leetcode 1706: Where Will the Ball Fall
You have a 2-D grid representing a box, and a number of balls that will be dropped into the box. The box has diagonal boards in each cell, which can redirect the balls either left or right. Your task is to determine the path of each ball dropped from the top of the box. The ball can either fall out of the bottom, or get stuck if it hits a ‘V’ shaped pattern between two boards or is redirected into a wall.
Leetcode 1712: Ways to Split Array Into Three Subarrays
You are given an array of non-negative integers. Your task is to count the number of ways the array can be split into three contiguous non-empty subarrays: left, mid, and right. The sum of the elements in the left subarray should be less than or equal to the sum in the mid subarray, and the sum of the mid subarray should be less than or equal to the sum of the right subarray. Return the number of such good splits modulo 10^9 + 7.
Leetcode 1718: Construct the Lexicographically Largest Valid Sequence
Given an integer n, find a sequence of length 2n - 1 that satisfies the following conditions:
- The integer
1occurs once in the sequence. - Each integer between
2andnoccurs twice in the sequence. - For every integer
ibetween2andn, the distance between the two occurrences ofiis exactlyi. - The sequence should be lexicographically the largest possible sequence.
The sequence is considered lexicographically larger if, at the first position where the two sequences differ, the number in the first sequence is greater.