Advertisement
rishu110067

Untitled

Jan 22nd, 2022
1,110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def get_permutations(arr):
  2.     # Write your code here
  3.     result=[]
  4.    
  5.     def helper(remaining,slate):
  6.        
  7.         if(len(remaining)==0):
  8.             result.append(list(slate))
  9.             return
  10.        
  11.         for i in range(len(remaining)):
  12.             slate.append(remaining[i])
  13.             helper(remaining[:i] + remaining[i+1:], slate)
  14.             slate.remove(remaining[i])
  15.        
  16.     helper(arr,[])
  17.     return result
  18.  
  19.  
  20. print(get_permutations(["A","B","C"]))
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement