How can I calculate the time complexity of this program? Is there a more efficient solution?
public class MinJumpstoEnd {
public static void main(String[] args) {
int[] a = {1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9};
//i is used for array elements & c to count jumps
int i =0,c =0;
int j = a[0];
while(a.length-i > j) {
if(a[i]==0) {
System.out.println("Cant Reach");
}
i += j;
c+=1;
j = a[i]-1;
System.out.println("j:"+j);
}
System.out.println("Jumps : "+c);
}
}