this code has Time complexity of O(n) or O(n^2)
please explain it also
Time complexity
@abhay_091
this time complexity of this is n^2 because you choose start point as b and your c variable is increasing cont. and when c reached the end position you increment b and move c back to b only and then the process repeat.
suppose your array size is n;
first iteration c will iterate over n elements
now second iteration you increment b and intialise c to b now c will iterate over n-1; elements
…
…
this process continues and it forms a AP
n+(n-1)+(n-2)+(n-3)+…1=n(n+1)/2
so time complexity will n^2