See following are the inputs array for $A . If its successful for 3 but fails for the last one.
//$A = array(9, 9, 4, 3, 5, 4, 5, 2, 8, 9, 3, 1); //got 3 expt 2
// 0 ,1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11 // Should be getting 4 , 6 , 9 for the first 2 search loops and then $counter should be = 2
//$A = array (1,5,3,4,3,4,1,2,3,4,6,2); Should be getting 1 3 5 10 for the first 2 search loops and then $counter should be = 3
//0,1,2,3,4,5,6,7,8,9,10,11 // 1 3 5 10 should be 3
//$A = array(4, 5, 8, 5, 1, 4, 6, 8, 7, 2, 2, 5); //expected 2
// 0 ,1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11 // 2 7
//$A = array(5, 9, 6, 2, 2, 7, 3, 2, 7, 4, 7, 9); // 1 5 8
// 0 ,1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11
//$A = array(7, 10, 4, 5, 7, 4, 6, 1, 4, 3, 3, 7);