Queue
Queue
Twenty-five questions on queues, for problems that process elements in the order they arrived.
First Unique Character in a String
easyGiven a string s, find the first non-repeating character in it and return its index.
Number of Students Unable to Eat Lunch
easyThe school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively.
Time Needed to Buy Tickets
easyThere are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line.
Continuous Subarrays
mediumYou are given a 0-indexed integer array nums.
Count Partitions With Max-Min Difference at Most K
mediumYou are given an integer array nums and an integer k.
Count Prime-Gap Balanced Subarrays
mediumYou are given an integer array nums and an integer k.
Dota2 Senate
mediumIn the world of Dota2, there are two parties: the Radiant and the Dire.
Find the Winner of the Circular Game
mediumThere are n friends that are playing a game.
Jump Game VI
mediumYou are given a 0-indexed integer array nums and an integer k.
Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
mediumGiven an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray...
Maximum Sum Circular Subarray
mediumGiven a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums.
Minimum Number of Coins for Fruits
mediumYou are given an 0-indexed integer array prices where prices[i] denotes the number of coins needed to purchase the (i + 1)th fruit.
Minimum Operations to Make Binary Array Elements Equal to One I
mediumYou are given a binary array nums.
Number of People Aware of a Secret
mediumOn day 1, one person discovers a secret.
Reveal Cards In Increasing Order
mediumYou are given an integer array deck.
Constrained Subsequence Sum
hardGiven an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence,...
Count Non-Decreasing Subarrays After K Operations
hardYou are given an array nums of n integers and an integer k.
Count Subarrays With Fixed Bounds
hardYou are given an integer array nums and two integers minK and maxK.
Delivering Boxes from Storage to Ports
hardYou have the task of delivering some boxes from storage to their ports using only one ship.
Find Maximum Non-decreasing Array Length
hardYou are given a 0-indexed integer array nums.
Longest Increasing Subsequence II
hardYou are given an integer array nums and an integer k.
Max Value of Equation
hardYou are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <=...
Maximize the Minimum Powered City
hardYou are given a 0-indexed integer array stations of length n, where stations[i] represents the number of power stations in the ith city.
Maximum Number of Robots Within Budget
hardYou have n robots.
Maximum Number of Tasks You Can Assign
hardYou have n tasks and m workers.