Free beta: free to use with daily limits while we build. Join the waitlist for founding-member pricing at launch. Join the waitlist

Sign up free

Google interview question

Group consecutive notes into hand positions and assign a finger to each note

Company:
Google
Type:
Coding
Difficulty:
Medium
Reported:
November 18, 2026

Problem

Given a sequence of notes (integers), split it into groups of consecutive notes, where each group is one hand position. One hand's five fingers cover five adjacent notes, so within a group the difference between the maximum and minimum note must be at most 4.

The hand stays in its current position as long as the next note still fits (the group's span stays at most 4). When the next note would make the span exceed 4, the hand moves: a new group starts at that note and moves increases by one. The starting hand position does not count as a move.

For each note, the finger number is note - (minimum note of its group), where 0 is the thumb and 4 is the pinky.

Return moves and the list of finger numbers.

Example 1

Input: notes = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
Output: moves = 1, fingering = [4, 3, 2, 1, 0, 4, 3, 2, 1, 0]

10 to 6 fit in one position (span 4); 5 would make the span 5, so the hand moves once and 5 to 1 form the second group.

Example 2

Input: notes = []
Output: moves = 0, fingering = []

Constraints

  • Not stated; ask the interviewer.

Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern