Compress Navigator Route Segments Into Street Level Instructions

Last updated: November 29, 2026

Quick Overview

A route is a list of (street_name, length_m) segments in driving order. Collapse consecutive segments on the same street into one instruction with the total length, keeping later returns to a street as separate instructions.

Yandex
Coding & Algorithms
Software Engineer
Yandex
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


A route is a list of (street_name, length_m) segments in driving order. Collapse consecutive segments on the same street into one instruction with the total length, keeping later returns to a street as separate instructions.

Yandex Navigator turns a graph path into spoken and on-screen maneuvers, and a run-length style compression of road segments is a fitting short task for an online assessment. The grader checks clean single-pass logic and that non-adjacent repeats are not merged.

What the Interviewer Expects
  • Single linear pass with a running last instruction
  • Merge only adjacent equal streets
  • Preserve the original order
  • Handle an empty route
  • Return immutable tuples or a clear output format
Key Topics to Cover
run-length encoding
arrays
linear scan
route maneuvers
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you also emit the turn direction between instructions given segment bearings?
  • What if a street name is missing for some segments (unnamed roads)?
  • How would you suppress instructions shorter than 30 meters?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: ordered list of (street, length). Output: ordered list of (street, total_length) where each element is a maximal run of consecutive segments on the same street. Example: Tverskaya 120, Tver...

High-Level Design

Run-length encoding keyed by street name. Keep the output list; if the current street equals the last output street, add to its length, otherwise start a new entry....


Submit Your Answer
Markdown supported

Related Questions