title: Full and half cycle calculation using simple array
body: <p>My program takes in random array inputs where the array has values of integers from 0-n and the letter &quot;M&quot; which stands for markers. Based on this array I have to determine how many cycles are in the array. The Input are</p>
  <blockquote>
  <p>[M,1,2,3,4,5,6] = One half cycle</p>
  <p>[M,1,2,3,4,5,6,M] = One full cycle</p>
  <p>[1,2,3,4,5,M] = One half cycle</p>
  <p>[1,2,3,4] = One half cycle</p>
  <p>[M, 1,2,3,4] = One half cycle</p>
  <p>[M,1,2,3,4,M,6] = One Full and one halfcycle</p>
  <p>[M,1,2,3,4,M,6,7,8,M] = Two Full Cycles</p>
  <p>[M,1,2,3,4,M,6,7,8,M,M,9] = Two Full Cycles and a half cycle</p>
  </blockquote>
  <p>How can i write code for this sort of logic?</p>