PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Snapchat

Solve rotating-lock BFS with blockers

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's understanding of state-space modeling, shortest-path search strategies, and constraint handling when navigating combinatorial configuration spaces.

  • Medium
  • Snapchat
  • Coding & Algorithms
  • Software Engineer

Solve rotating-lock BFS with blockers

Company: Snapchat

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

You are given a 4-digit lock starting at "0000". In one move, you may pick a single position and rotate it +1 or −1 with wrap-around (0→9 on −1, 9→0 on + 1). Given a target combination and a list of forbidden combinations (you cannot enter these states), return the minimum number of moves required to reach the target from "0000", or −1 if it is impossible. Implement an efficient solution and write unit tests covering: target equals "0000"; forbidden includes "0000"; unreachable targets; duplicate entries in the forbidden list; and large forbidden sets.

Quick Answer: This question evaluates a candidate's understanding of state-space modeling, shortest-path search strategies, and constraint handling when navigating combinatorial configuration spaces.

Related Interview 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)
Snapchat logo
Snapchat
Jul 31, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

You are given a 4-digit lock starting at "0000". In one move, you may pick a single position and rotate it +1 or −1 with wrap-around (0→9 on −1, 9→0 on + 1). Given a target combination and a list of forbidden combinations (you cannot enter these states), return the minimum number of moves required to reach the target from "0000", or −1 if it is impossible. Implement an efficient solution and write unit tests covering: target equals "0000"; forbidden includes "0000"; unreachable targets; duplicate entries in the forbidden list; and large forbidden sets.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snapchat•More Software Engineer•Snapchat Software Engineer•Snapchat Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ 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.