finding subarrays

hello guys! I am a beginner in the world of programming. Most of the time i get stucked in the problems where i m required to find the subarrays of a given array. Can you please suggest an effective and easy to implement method to find all the subarrays of a given array?
THANK YOU

we can find all subarrays of arrays with using two loops.


 `for(int i=0;i<n;i++)
      for(int j=i;j<n;j++)
            print(array[i to j])
`

 Its a naive approach.But based on our problem statement we can optimize.

remember one thing there is a difference between subarray and subset.
to make all subsets it will take O(2^n) time.
2 Likes

arrays means we are playing with storage locations, programmatically playing with indexes,in java we can split arrays using parameters.if you found the logic between the arrays and sub arrays,generation of sub arrays and playing with those is easy