23. DSA with C++ - Standard Queue Questions

Standard Queue Questions

Queue-related questions are commonly asked in technical interviews, including those conducted by FAANG (Facebook, Amazon, Apple, Netflix, Google) and other top tech companies. Here are some standard queue questions that often come up in interviews:
  1. Implement Queue using Stacks: Design a queue using two stacks and implement its enqueue, dequeue, and isEmpty operations efficiently.
  2. Sliding Window Maximum: Given an array and an integer k, find the maximum element for each contiguous subarray of size k.
  3. Implement a Circular Queue: Implement a circular queue with a fixed size and support the enqueue, dequeue, and isEmpty operations.
  4. Design a Recent Counter: Design a data structure to count the number of recent requests within a time range. Implement the ping(int t) method that records a new request at time t and returns the number of requests made in the last 3000 milliseconds.
  5. Reconstruct Queue: Given a list of people with their heights and the number of people in front of them, reconstruct the queue of people based on this information.
  6. First Unique Integer in a Stream: Given a stream of integers, find the first unique integer at each step.