Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Contradictory between the code and the description, the description says "we are...

Nuttapong Saelek

Mar 7, 2023

Contradictory between the code and the description, the description says "we are iterating through all of these permutations with the help of the two β€˜for’ loops". Apparently, from the code, we make 3 loops.

Should the time complexity be O(N^2*N!) instead?

1

0

Comments
Comments
N
Nuttapong Saelek3 years ago

My bad, you did mention the permutations' iteration, but my question still holds, for each permutation, we have to iterate up to N! combination, and for every N! combination we can fill the permutation up to N+1 ways. Therefore O(N^2*N!), isn't it?

On this page