Permutations - Leetcode 46 - Recursive Backtracking (Python)

preview_player
Показать описание


Please check my playlists for free DSA problem solutions:

My Favorite Courses:

Data Structures & Algorithms:

Python:

Web Dev / Full Stack:

Cloud Development:

Game Development:

SQL & Data Science:

Machine Learning & AI:
Рекомендации по теме
Комментарии
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

Greg you have natural talent in teaching, kindly don’t stop making videos

shreehari
Автор

After watching 3 different vids for this problem, this was the only solution where the code made intuitive sense to me, thanks for this fr

jonTheDon
Автор

Dude I like your solutions because they are always so clean and the fact that you don't use "pythonic code" makes it so much more easier to understand. So many other people abuse python shortcuts that makes the code impossible to understand

DamosyTheFreckle
Автор

I learned backtracking thanks to you, thanks Greg!

christianjt
Автор

such an elegant explanation. Thanks Greg!

AbhishekYadav-ywkv
Автор

Love your approach. So easy to understand

vidhinagda
Автор

This is great. Explanations are so clear. Thank you

mhkhan
Автор

I think both the time and space complexity is O(n x n!), because of copying the the arr in this case sol[ : ].
Also for the space, it's going to contain n! results, and each of them are of length n, and hence O(n x n!)

surafelgetachew
Автор

this solution is so much more understandable! thank you

arthurpongsapak
Автор

Finally got a hang of backtracking because of you 🙏

rathangpandit
Автор

This is a really intuitive solution, thank you!

slater-cguy
Автор

Time complexity is = n! * n (becoz each leaf node is reached in n steps)

prannoyroy
Автор

I think this problem is purely a test of how to code it concisely.
Leetcoding to land a Meta/Google position.
Gotta use code that interviewers can read... so found 3 solutions:
Dupes
Insertion into a growing temp linkedList
Rotations
Took me a couple hours to solve on my own, giving up, then looking it up.

jz
Автор

should the checking of x in sol be counted inside the time complexity? if so, this will be O(n.n!)

Techgether
Автор

Wouldn't the time complexity be O(n! * n) since we're checking each time if x is not in sol?

Steel
Автор

Wouldn't the space complexity be exponential if we consider the recursion stack?

arunselvannatesan
Автор

Woow ! You made look so simple . Good job. Keep doing such videos

HemanthKumar-vloh
Автор

been coding for 1-2 months and im getting into these, my brain hurts

spec
Автор

My brain hurts.
Kind of understood it after watching many times

saleheen