-2

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

Willeke
  • 14,578
  • 4
  • 19
  • 47
user103485
  • 13
  • 1
  • 2
  • 4

2 Answers2

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
-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:

How to generate all permutations of a list in Python

Shen Huang
  • 11
  • 4