Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Circular Array Printing
00:00
5 left

Circular Array Printing

EasyPython

Problem

Photon's event viewer stores event identifiers in an array. Given a starting index, return every event exactly once by traversing forward and wrapping from the last element back to the first.

The traversal must preserve the array's circular order. For example, starting at index 2 in a five-element array visits indices 2, 3, 4, 0, 1.

Formal Specification

Implement circular_order(events, start_index):

  • events is a non-empty list of values.
  • start_index is an integer from 0 through len(events) - 1.
  • Return a new list containing all elements of events, beginning at start_index and continuing forward with wraparound.
  • Do not modify events.

Constraints

  • 1 <= len(events) <= 10^5
  • 0 <= start_index < len(events)
  • events may contain duplicate values
  • The input list must not be modified

Function Signature

def circular_order(events, start_index):
Interviewer

Your question is Circular Array Printing. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.