Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Rotate a shift schedule

Python data engineering interview problem. Difficulty: beginner. Pattern: Sorting. About 10 minutes. Part of the Pro drill bank.

A store roster is a list of names in shift order. Operations sometimes rotate the list so yesterday's closer opens today, wrapping names from the end back to the front.

Rotate the shift list by k positions as specified, wrapping around the end.

Requirements

  • Rotation wraps; names are not dropped.
  • Handle k larger than the list length and k = 0.

Constraints

  • names: list of employee names in current order.
  • k: how far to rotate.
  • Do not assume k is smaller than len(names).

Examples

Input: rotate_roster(['Ann', 'Bea', 'Cal'], 1) Output: ['Cal', 'Ann', 'Bea'] This input follows the stated rules and produces this output.

Topics: lakebench, python, lists.

More Python interview questions · All interview problems · Learn data engineering

beginner

Rotate a shift schedule

Interview-style drill: Rotate a list of employee names by a given number of positions.

Rotate the shift list by `k` positions as specified, wrapping around the end.