FastPrepRadar Barrier Crossing
Problems/Radar Barrier Crossing

Radar Barrier Crossing

Snap Inc. logoSnap Inc.● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Snap Inc. onsite interview. The report describes groups of overlapping radars and a test for a vertical barrier across a rectangle. It does not give number limits or say how touching edges count. Our version is about 95% the same as the reported question.

A rectangular area spans 0 <= x <= width and 0 <= y <= height. Each row [x, y, radius] in radars describes a circular detection region centered inside the rectangle, including the circle’s boundary.

An object wants to travel continuously from the left wall to the right wall without entering or touching any detection region. Two radar regions belong to the same connected group if they overlap or touch, either directly or through a chain of other radars.

A left-to-right undetected crossing is impossible exactly when one connected radar group touches both the bottom wall and the top wall. Return true when an undetected crossing is possible; otherwise return false.

Function

canCrossUndetected(width: int, height: int, radars: int[][]) → boolean

Examples

Example 1

width = 10height = 10radars = [[5,2,3],[5,8,3]]return = false

The two circles touch. The lower one reaches the bottom wall and the upper one reaches the top wall, so their component forms a complete barrier.

Example 2

width = 12height = 10radars = [[2,2,2],[6,2,2],[10,2,2]]return = true

The horizontal component touches the bottom wall but not the top wall, so it does not separate the left and right walls.

Example 3

width = 8height = 6radars = []return = true

With no detection regions, an undetected left-to-right route exists.

Constraints

  • 1 <= width, height <= 10^9.
  • 0 <= radars.length <= 1000.
  • Every radar row contains exactly [x, y, radius].
  • 0 <= x <= width and 0 <= y <= height.
  • 0 <= radius <= 10^9.
  • Circle overlap, tangency, and wall contact are inclusive.
  • Use 64-bit arithmetic for squared-distance comparisons.

More Snap Inc. interview questions

  • Render an Org Chart and Find Skip-Level PairsONSITE INTERVIEW · Seen Nov 2026
  • Peak of an Increasing-Then-Decreasing ArrayONSITE INTERVIEW · Seen Oct 2026
  • Number of Closed IslandsONSITE INTERVIEW · Seen Oct 2026
  • Sort Characters by FrequencyONSITE INTERVIEW · Seen Sep 2026
  • Dictionary Records to an Editable XML TreeONSITE INTERVIEW · Seen Aug 2026
  • Metric Counter with a Fake ClockONSITE INTERVIEW · Seen Aug 2026
  • ID Allocator with Assign and ReleasePHONE SCREEN · Seen Nov 2026
  • Basic Calculator IIPHONE SCREEN · Seen Oct 2026
  • Stream Cluster Max and MedianPHONE SCREEN · Seen Oct 2026
  • LRU Cache with Thread-Safety Follow-UpPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Accounts MergeOracle · ONSITE INTERVIEWOracle interview questions
  • Count Connected Point ClustersGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Number of Islands IIAmazon · ONSITE INTERVIEW
  • Find All People With SecretIDFC Bank · ONSITE INTERVIEWIDFC Bank interview questions
  • Group Linked Merchant RecordsStripe · PHONE SCREENStripe interview questions
  • Group Sparse Points by Distance ThresholdNuro · PHONE SCREENNuro interview questions
  • Count Islands in a Binary GridApple · PHONE SCREENApple interview questions
  • Detonate Bombs with Chain ReactionsAirbnb · PHONE SCREENAirbnb interview questions
  • Recoverable Elements from Range-Sum MeasurementsEthos Life · OA
  • Number of Islands IISpaceX · PHONE SCREENSpaceX interview questions

Interview reports that mention this question

  • Snap AI Coding Interview, Experienced SWE and MLE: 4 Experiences

Snap Inc. interview experiences

  • Snap Experienced MLE Onsite Interview Questions: 1 Experience
  • Snap Experienced MLE Virtual Onsite: 1 Experience
All Snap Inc. interview questionsSee Snap Inc. hiring insights
Saved
class Solution {
    public boolean canCrossUndetected(int width, int height, int[][] radars) {
        // Write your code here.
    }
}
Checking account…