Subarray generation

how sub array is generated using 2 loops

hello @divyam_13
by using 2 loops we can decide starting and ending index of the subarray.
ex->
for(int i=0 ; i < n ; i + + ){
for ( int j = i ; j < n ; j ++ ) {
here i is starting index of subarray and j is ending index of the considered subarray

}

}

but in this case ending index will always be n
for example if input array is 1,2,3
then it will only print 1,2,3 and 2,3 not 1,2

no , it will print all valid subarray.
try to code it and see the output

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.