Hi guys,

I have been practicing leetcode problem for facebook interview. I came across quite a bit of interesting problems on their forum. I wish to make 2 threads a week for 2 problems. Today, I want to share this problem and hope to discuss this problem with you guys

Problem statement:

Define amazing number as: its value is less than or equal to its index. Given a circular array, find the starting position, such that the total number of amazing numbers in the array is maximized.

Example 1: 0, 1, 2, 3

Ouptut: 0. When starting point at position 0, all the elements in the array are equal to its index. So all the numbers are amazing number.

Example 2: 1, 0 , 0

Output: 1. When starting point at position 1, the array becomes 0, 0, 1. All the elements are amazing number.

If there are multiple positions, return the smallest one