How to find all the subarrays of a given array in the fastest possible way? for eg:a=[1,2,3,4,5] The purpose of question is to large array input and find all the possible saubarrays
Asked
Active
Viewed 1.0k times
-2
-
1Did Google say "zero results found" ? – mad_ Jun 01 '18 at 17:39
2 Answers
0
def sub_lists(my_list): subs = [[]] for sub in my_list:subs += [i + [sub] for i in subs] return subs

Nandish Patel
- 116
- 13
-
Lets say the input list is [5,7,1]. We don't get [1,5] subarray in output – mbxzxz Sep 03 '21 at 18:00
-1
Now sure what you meant by sub arrays, but sounds like you want all the permutations of the contents in a given array. Which can be found here:

Shen Huang
- 11
- 4