Queue

Queue

Twenty-five questions on queues, for problems that process elements in the order they arrived.

First Unique Character in a String

easy
Given a string s, find the first non-repeating character in it and return its index.

Number of Students Unable to Eat Lunch

easy
The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively.

Time Needed to Buy Tickets

easy
There 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

medium
You are given a 0-indexed integer array nums.

Count Partitions With Max-Min Difference at Most K

medium
You are given an integer array nums and an integer k.

Count Prime-Gap Balanced Subarrays

medium
You are given an integer array nums and an integer k.

Dota2 Senate

medium
In the world of Dota2, there are two parties: the Radiant and the Dire.

Find the Winner of the Circular Game

medium
There are n friends that are playing a game.

Jump Game VI

medium
You are given a 0-indexed integer array nums and an integer k.

Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit

medium
Given 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

medium
Given 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

medium
You 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

medium
You are given a binary array nums.

Number of People Aware of a Secret

medium
On day 1, one person discovers a secret.

Reveal Cards In Increasing Order

medium
You are given an integer array deck.

Constrained Subsequence Sum

hard
Given 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

hard
You are given an array nums of n integers and an integer k.

Count Subarrays With Fixed Bounds

hard
You are given an integer array nums and two integers minK and maxK.

Delivering Boxes from Storage to Ports

hard
You have the task of delivering some boxes from storage to their ports using only one ship.

Find Maximum Non-decreasing Array Length

hard
You are given a 0-indexed integer array nums.

Longest Increasing Subsequence II

hard
You are given an integer array nums and an integer k.

Max Value of Equation

hard
You 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

hard
You 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

hard
You have n robots.

Maximum Number of Tasks You Can Assign

hard
You have n tasks and m workers.