URGENT- Find all sub arrays of a given array.

Hey guys, can you please help me out on this one? I need a code to find/print all possible sub-arrays for a given array (for quiz exam today). I searched google but I cannot get a relevant understandable code, so if you guys can be generous enough to give one such code, I would be grateful!

You can go for the bit-mask method to generate all the possible sub-arrays of an array!!
But the complexity can go to 2^n…!!

1 Like

@kashyap you method is to find all the subsets. He wants to find all subarrays which can be done in n^3.

Remember, subarrays are continuos.

1 Like

Complexity doesn’t matter as input would be small (they don’t wish to test time complexity). Can you please post a code for this? I am not familiar with that method. Thanks in advance!!

No, sub arrays need not be contiguous. Sorry for any ambiguity from my side! You can consider it as “sub-sets” dear :slight_smile:

1 Like

Thanks for help guys, I was able to figure the method out. Thanks for your time!! :slight_smile: