PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This set of problems evaluates competencies in streaming data handling and incremental aggregation, time-dependent grid traversal and reachability under dynamic hazards, and planar path existence with geometric obstacles, touching on data structures, graph algorithms, and computational geometry within the Coding & Algorithms domain.

  • Snapchat
  • Coding & Algorithms
  • Software Engineer

Solve Three Coding Problems

Company: Snapchat

Role: Software Engineer

Category: Coding & Algorithms

Interview Round: Onsite

The interview included three coding problems: 1. **Streaming top-k class.** Design a class for an integer stream with a fixed parameter `k`. It should support `add(x)` to ingest a new value and `getTopK()` to return the `k` largest values seen so far in descending order. If fewer than `k` values have appeared, return all of them. Aim for efficient incremental updates. 2. **Maximum safe delay in a burning grid.** You are given an `m x n` grid containing empty cells, walls, and initial fire sources. Fire spreads every minute to the four neighboring non-wall cells. A person starts at the top-left cell and wants to reach the bottom-right cell. Before moving, the person may wait for `t` minutes at the start, then moves one step per minute through non-wall cells. The person may never enter a cell after the fire has arrived there; arriving at the destination at the same minute as the fire is allowed. Return the maximum `t` that still allows escape, return `-1` if escape is impossible even with no waiting, and return `1000000000` if escape is possible for arbitrarily large `t`. 3. **Reachability in a rectangle with circular blockers.** You are given a rectangle with corners `(0, 0)` and `(X, Y)`, along with several closed circles inside or touching the rectangle. Determine whether there exists a continuous path from `(0, 0)` to `(X, Y)` that stays within the rectangle and never touches or enters any circle. The path may move in any direction.

Quick Answer: This set of problems evaluates competencies in streaming data handling and incremental aggregation, time-dependent grid traversal and reachability under dynamic hazards, and planar path existence with geometric obstacles, touching on data structures, graph algorithms, and computational geometry within the Coding & Algorithms domain.

Streaming Top-K Values

After each added integer, return the k largest values seen so far in descending order.

Constraints

  • k >= 0

Examples

Input: (3, [5, 1, 9, 3, 10])

Expected Output: [[5], [5, 1], [9, 5, 1], [9, 5, 3], [10, 9, 5]]

Explanation: Maintains top three.

Input: (0, [1, 2])

Expected Output: [[], []]

Explanation: k=0 returns empty lists.

Input: (5, [2, 2, 1])

Expected Output: [[2], [2, 2], [2, 2, 1]]

Explanation: Fewer than k values.

Hints

  1. Keep a min-heap of the current top k values.

Maximum Safe Delay in a Burning Grid

Return the largest start wait that still permits escape from top-left to bottom-right as fire spreads.

Constraints

  • grid values: 0 empty, 1 fire source, 2 wall
  • Arriving at destination at the same time as fire is allowed

Examples

Input: ([[0, 0], [0, 0]],)

Expected Output: 1000000000

Explanation: No fire means arbitrary waiting.

Input: ([[0, 1], [0, 0]],)

Expected Output: -1

Explanation: Escape can be impossible immediately.

Input: ([[0, 0, 0], [2, 2, 0], [1, 0, 0]],)

Expected Output: -1

Explanation: Finite waiting case.

Hints

  1. Precompute fire arrival times, then binary-search the waiting time with BFS feasibility.

Rectangle Path with Circular Blockers

Return whether a continuous path exists from (0,0) to (X,Y) without touching or entering closed circles.

Constraints

  • Circles are closed blockers

Examples

Input: (10, 10, [])

Expected Output: True

Explanation: No blockers.

Input: (10, 10, [(0, 5, 1)])

Expected Output: True

Explanation: Circle touching only left boundary need not block.

Input: (10, 10, [(5, 5, 6)])

Expected Output: False

Explanation: Endpoint-free but boundary-spanning blocker.

Input: (10, 10, [(1, 1, 2)])

Expected Output: False

Explanation: Start inside a circle.

Hints

  1. Union touching/overlapping circles and rectangle boundaries; certain boundary connections block all paths.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Determine Whether Courses Can Be Completed - Snapchat (medium)
  • Solve Decimal Coin Change - Snapchat (medium)
  • Find Maximum Island Perimeter - Snapchat (medium)
  • Solve Three Algorithmic Tasks - Snapchat (hard)
  • Implement a Timestamped Counter - Snapchat (medium)