Company: Pocketpills Backend Engineer Intern Oncampus_18july
Difficulty: medium
You are managing a row of street lamps arranged in a circular park. Each lamp shows a number representing its current brightness level . Every night you can perform one adjustment step. During one step, every lamp simultaneously adopts the brightness of itself or of one of its two immediate neighbours (the row is circular, so the first and last lamps are neighbours). All lamps read the previous night's values when they decide. Your task is to determine the minimum number of nights required to make all lamps show the same brightness. Input Format A single line containing N integers, representing the brightness of each lamp in order around the circular park. Output Format Print a single integer — the minimum number of nights required for all lamps to have the same brightness. Constraints 1 ≤ N ≤ 10 5 1 ≤ brightness ≤ 10 9 Sample Testcase 1 Input 1 2 1 2 1 2 Output 1 Explanation: Every lamp already has a neighbour showing brightness 1 , so after a single night all six la