Permutations Leetcode 46

preview_player
Показать описание
Permutations Leetcode 46
Рекомендации по теме
Комментарии
Автор

during PR review: "why not use the builtin function; pls fix thx"

mdwilson
Автор

He said he is not gonna pass the interview.😂😂

joelosteen
Автор

A choice without recursion would be looping through each new character in your source array, then each set in your answer array to generate a new list of permutations at each step.

It's a bit less elegant, but hopefully the sample data isn't malicious enough to give you recursion depth errors. (although..you'll most definitely run out of memory with your results before generating enough permutations for recursion depth to be an issue)

chrisgoal
Автор

The best solution is O(N!) Simply by the nature of this question. Good thing its not an array of 52, for a deck of cards or 54 for 52 + 2 jokers, it will never finish!

islandcave
Автор

I am pretty sure rewriting an already built in library function is more at risk of making you fail an interview than just using the built in.

I have failed an interview for doing just that in fact.

xXJMXx
Автор

Don’t understand. Need help explaining

彩色糖果-ii
Автор

Its too complex… can’t understand it in short video

ASHAYJPATEL
Автор

theres a better way to do this i just dont see it...
```
def merge(*tree):
something iterate and join n nodes

def thing(x):
for i in x:
a = x.slice remove (i)
return i.append(thing(x))

def whatever(x):
tree = thing(x)
return merge(tree)
```
need a list without element type of construct with a for loop, whatever that is have it operate before thing. and do bounds for length, idk need to have a function which externalizes the loop so it returns multiple lists... its late wdyw!

are these just interview traps?

ravenecho
Автор

BRO THIS HAS A BUILT IN FUNCTION THE WAY I BUSTED MY BEHIND TO LEARN A ALGORITHM TO COMPUTE PERMUTATIONS😃😃😃🤣

basil