Algorithm to find ideal starting spot in a circle : <p>So the problem I have been debating is as such:</p>

<p>Your are given an array of integers representing a circle. Then, you have to pick spot in the circle to start. From the place you start, you compare the value at the array to number of steps you took to get there and if the steps are less than or equal to the number, include it in your final set. Find the place to start so that you have the most elements in your set.</p>

<pre><code>ex, a=[0, 1, 2]

If you start at index=0, then:
a[0]=0 &lt; =0 so 0 is included
a[1]=1 &lt; =1 so 1 is included
a[2]=2 &lt; =2 so 2 is included

final set: {0,1,2}


If you start at index=1, then:
a[1]=1 &gt; 0 so 1 is NOT included
a[2]=2 &gt; 1 so 2 is NOT included here we loop back around
a[0]=0 &gt; 2 so 0 is included

final set: {0}

If you start at index=2, then:
a[2]=2 &gt; 0 so 2 is NOT included, here we loop back around
a[0]=0 &lt; = 1 so 0 is included 
a[1]=1 &lt; = 2 so 1 is included

final set: {0,1}
</code></pre>

<p>So in this trivial case, starting position index=0 is the best position as it results in the final set with the most elements. Now the brute force method of finding this is obvious, but I am trying to find a more efficient method. My attempts so far have been to examine trying to find the max intersect of viable starting ranges calculated for each element in the array. Also, I feel like dynamic programming can be used in some way to help make the solution but I can't seem to identify exactly how.</p>
