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 1717: Maximum Score From Removing Substrings
You are given a string s
and two integers x
and y
. You can perform two types of operations any number of times:
- Remove the substring “ab” and gain
x
points. - Remove the substring “ba” and gain
y
points.
Each time a substring is removed, the characters are deleted from the string, and the corresponding points are added to your total score. Your task is to maximize the total score after applying these operations any number of times.