Facebook Pixel

Should I write an O(N!) algorithm in an interview?

Only if the problem explicitly asks for all permutations or combinations. If they ask for a shortest path or optimal solution, an O(N!) brute force is just a starting point.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Recognizing O(N!) Factorial Time Complexity

It is an extreme time complexity where the operations multiply factorially (N * N-1 * N-2...), representing the absolute worst algorithmic scaling possible.

Problems that require generating all possible permutations (orderings) of a dataset, such as solving the brute-force Traveling Salesperson problem.

Yes, drastically worse. 20^2 is 400. 2^20 is 1 Million. 20! is 2.4 Quintillion.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.