Permutations - Leetcode 46 - Python

  Рет қаралды 8,255

NeetCodeIO

NeetCodeIO

Күн бұрын

🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🧑‍💼 LinkedIn: / navdeep-singh-3aaa14161
🐦 Twitter: / neetcode1
⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
Problem Link: neetcode.io/problems/permutat...
0:00 - Read the problem
0:30 - Drawing Explanation
6:08 - Coding Recursive
9:35 - Coding Iterative
leetcode 46
#neetcode #leetcode #python

Пікірлер: 17
@hasferrr
@hasferrr 9 күн бұрын
i think the backtracking solution with decision tree is more intuitive. For each recursion call, you can store the number that has already added to the Answer list into the HashSet, and for each recursion call you can skip the number that already in the HashSet function permute(nums: number[]): number[][] { const result = [] const dfs = (set: Set, pm: number[]): void => { if (pm.length === nums.length) { result.push([...pm]) return } for (let i = 0; i < nums.length; i++) { if (set.has(nums[i])) { continue } pm.push(nums[i]) set.add(nums[i]) dfs(set, pm) pm.pop() set.delete(nums[i]) } } dfs(new Set(), []) return result }
@riddle-master-ruben
@riddle-master-ruben 23 күн бұрын
This is a way better explanation than the old video. I went months with this problem unsolved because I just couldn't understand, but this explanation helped me tremendously. Thanks!
@bandarupawankumar7549
@bandarupawankumar7549 23 күн бұрын
Thank you neetcode for again working on this problem :)
@MyPodie
@MyPodie 23 күн бұрын
Morning Neetcode!
@pastori2672
@pastori2672 23 күн бұрын
i feel like a time traveler
@johnveracruz2102
@johnveracruz2102 23 күн бұрын
@NeetcodeIO PLS add a functionality on your site to not show the topics for the questions. want to do them in order without knowing the topic. thanks
@AVGVSTVSivlivs
@AVGVSTVSivlivs 20 күн бұрын
Swapping indices method for this question is probably more clear and you should also review Longest Palindromic Substring question. Solutions in the other questions are quite optimal. Thanks a lot!
@Gomeroff
@Gomeroff 23 күн бұрын
I live in Russia, a new day has not yet begun, and you are already solving a new problem)
@user-vu4ng4rb8k
@user-vu4ng4rb8k 23 күн бұрын
hey also do video for cherry pickup 1 and bst to sorted DLL
@kanjurer
@kanjurer 23 күн бұрын
I actually just solved the problem yesterday lmao
@ijavd
@ijavd 23 күн бұрын
Morning
@mukeshrawat1304
@mukeshrawat1304 23 күн бұрын
Is it possible for you to have some sort of poll or something where we could ask for a video solution of a leetcode problem which you haven't already solved. Because there are quite a few problems which don't have a proper solution on KZbin and God knows when they will appear as POTD.
@DeathSugar
@DeathSugar 23 күн бұрын
I guess thats what his site is for.
@pushkarsaini2
@pushkarsaini2 23 күн бұрын
Now Solve 31 Next Permutation
@m_jdm357
@m_jdm357 10 күн бұрын
The worst solution I've seen.
@NeetCodeIO
@NeetCodeIO 9 күн бұрын
anything specific about it that you did not like?
@m_jdm357
@m_jdm357 9 күн бұрын
@@NeetCodeIO I tried to understand it but it's really bad when debugging or writing down on paper. Really hard to understand. I found this solution: def permute(self, nums: List[int]) -> List[List[int]]: res = [] def backtrack(arr): if len(arr) == len(nums): res.append(arr.copy()) return for i in range(len(nums)): if nums[i] in arr: continue arr.append(nums[i]) backtrack(arr) arr.pop() backtrack([]) return res This I got. If no one supports me and everyone thinks your solution is good. Then I'm wrong.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 351 М.
Backtracking: Permutations - Leetcode 46 - Python
9:43
NeetCode
Рет қаралды 336 М.
БОЛЬШОЙ ПЕТУШОК #shorts
00:21
Паша Осадчий
Рет қаралды 11 МЛН
A clash of kindness and indifference #shorts
00:17
Fabiosa Best Lifehacks
Рет қаралды 104 МЛН
Cat Corn?! 🙀 #cat #cute #catlover
00:54
Stocat
Рет қаралды 15 МЛН
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 580 М.
Leetcode 46. Permutations : Introduction to backtracking
10:06
ComputerBread
Рет қаралды 89 М.
Permutations - Leetcode 46 - Recursive Backtracking (Python)
9:42
One second to compute the largest Fibonacci number I can
25:55
Sheafification of G
Рет қаралды 66 М.
10 Math Concepts for Programmers
9:32
Fireship
Рет қаралды 1,8 МЛН
The Unfair Way I Got Good At LeetCode
23:02
Aman Manazir
Рет қаралды 66 М.
Maximum Total Importance of Roads - Leetcode 2285 - Python
9:59
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 140 М.
Doing LeetCode Be Like (Coding Interviews Be Like Pt. 2)
4:41
Nicholas T.
Рет қаралды 750 М.
Красиво, но телефон жаль
0:32
Бесполезные Новости
Рет қаралды 1,3 МЛН
СТРАШНЫЙ ВИРУС НА МАКБУК
0:39
Кринжовый чел
Рет қаралды 1,4 МЛН
Как правильно выключать звук на телефоне?
0:17
Люди.Идеи, общественная организация
Рет қаралды 1,7 МЛН
iPhone, Galaxy или Pixel? 😎
0:16
serg1us
Рет қаралды 606 М.
$1 vs $100,000 Slow Motion Camera!
0:44
Hafu Go
Рет қаралды 25 МЛН