🎒
Technical Interview Study Guide
  • 🍕Welcome!
  • 🍥Getting Started
    • Study Plan
    • Optimizing Revision
    • Summer 2024 Timeline
    • FAQs
  • 🥨Algorithms
    • Binary Search
    • Sorting
    • Recursion
    • Graph
    • Quick Select
    • Intervals
    • Binary
    • Geometry
    • Dynamic Programming
  • 🥞Data Structures
    • Arrays
      • Matrices
    • Strings
    • Linked Lists
      • Doubly Linked Lists
    • Hash Tables
    • Graphs
      • Trees
        • Binary Search Trees
        • Heaps
        • Tries
        • Segment Trees
    • Stacks
    • Queues
      • Double Ended Queues
    • Union-Find Disjoint Set (UFDS)
  • 🍡Problems Guide
    • Dynamic Programming Roadmap
      • Warmup
        • Climbing Stairs
        • Nth Tribonacci Number
        • Perfect Squares
      • Linear Sequence
        • Min Cost to Climb Stairs
        • Minimum Time to Make Rope Colorful
        • House Robber
        • Decode Ways
        • Minimum Cost for Tickets
        • Solving Questions with Brainpower
  • 🍣Other Technical Topics
    • General Problem Solving
    • Runtime Predictions
    • System Design
      • SQL
      • Accessing APIs
    • Operating Systems
  • 🍿Non-technical Topics
    • Behavioral Interviews
    • Resumes
Powered by GitBook
On this page
  • Runtime analysis
  • Take note…
  • Corner cases
  • Techniques
  • Rotating the queue on itself
  1. Data Structures

Queues

Queue problems are less common but it is still a data structure that is worth understanding well

Runtime analysis

  1. Enqueue/offer: O(1)O(1)O(1)

  2. Dequeue/poll: O(1)O(1)O(1)

  3. Front: O(1)O(1)O(1)

  4. Back: O(1)O(1)O(1)

  5. isEmpty: O(1)O(1)O(1)

Take note…

  1. Built in data structure like [] in Python use O(n)O(n)O(n), not O(1)O(1)O(1)

    • Check if can assume data structure is optimal

    • To optimize for Python, use from collections import deque instead to popleft()

Corner cases

  1. Empty queues

  2. Queue with one item

  3. Queue with two items

Techniques

Rotating the queue on itself

Pop the queue and push back onto itself to bring the last element to the front

PreviousStacksNextDouble Ended Queues

Last updated 1 year ago

🥞