Music Festival Lineup Challenge

Company: Accolite_17oct

Difficulty: medium

Problem Statement

Music Festival Lineup Challenge Problem Description A music festival has finished booking its slots. Every booking is an ordered pair of performers (from, to) , meaning that performer to is scheduled to walk on stage immediately after performer from . Each performer is identified by a stage name made of lowercase letters. The festival now has to publish the running order for the night. A valid running order is a sequence of stage names such that: it starts with the performer named "starter" , who always opens the show; every consecutive pair in the sequence is one of the booked pairs; and every booked pair is used exactly once — a booking that was paid for cannot be skipped, and it cannot be played twice. Several valid running orders may exist. Publish the one that is lexicographically smallest when the sequence is compared stage name by stage name. It is guaranteed that at least one valid running order exists. Note that a performer may appear more than once in the running order: that