Word Search - Leetcode 79 - Recursive Backtracking (Python)

  Рет қаралды 4,961

Greg Hogg

Greg Hogg

Күн бұрын

Пікірлер
@GregHogg
@GregHogg 4 ай бұрын
Master Data Structures & Algorithms For FREE at AlgoMap.io!
@nikoschaitas1378
@nikoschaitas1378 2 ай бұрын
Seems like they added another test case that will prevent you from submitting successfully. board = [["a"]] word = "ab" In C++, you could do the following check before m==1 && n==1: if (word.size() > m*n) return false; At least it worked for me, with a not so pretty runtime of 576 ms. Again, thanks Greg! Probably wouldn't have understood the problem without this video!
@MaHyxa
@MaHyxa 2 ай бұрын
Hey Greg, thanks for the lesson. Just want to let you know that on your GitHub java solution you dont need this statement: if (m == 1 && n == 1) { return board[0][0] == word.charAt(0); } because it's failing test with a single letter in a board and always returning true without checking size of the word. And also you've declared a variable W, but never used it in code.
@nikhilsastry6631
@nikhilsastry6631 6 ай бұрын
Hey greg ... Can you make a video or make a pdf of something that consists all strings based ir other all category algorithms ... I want particularly for string like kmp ..m can you put all the algos at one place from easy to hard
@GregHogg
@GregHogg 6 ай бұрын
This question is part of a playlist that has all the leetcode questions I've done on there so far. I also have them in mini playlists organized by category. I hope this helps!!
@dominikschweigl574
@dominikschweigl574 6 ай бұрын
Doesnt that mean your solution doesnt work whenever the word is taking up the whole grid? Like in the example for 1x1 there is nowhere to go to and it would return false, right?
@GregHogg
@GregHogg 6 ай бұрын
Actually, no, this is not the case. It's particularly when there's exactly one spot. From the position on the last character, the board would just need literally any valid space to go to. Even if that space was marked as a hashtag or a character or whatever, it just needs an actual valid (i,j) position to move to
@polidon1577
@polidon1577 Ай бұрын
would it be possible to store dead end sequences with the positions so that if you have a second attempt reach there in the same way, it would cancel early instead of tracing the whole word? I think that would help reduce the time complexity but I'm not sure how much that would impact the space complexity if it's even viable to do so
@thatnolan
@thatnolan 5 ай бұрын
Any reason to use pos in backtrack() instead of i, j? You change it back to i, j in the first time anyways. The efficiency goes up quite a bit when changing pos to i, j
Rotting Oranges - Leetcode 994 - Graphs (Python)
16:09
Greg Hogg
Рет қаралды 3,4 М.
This Game Is Wild...
00:19
MrBeast
Рет қаралды 152 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 6 МЛН
How to Enable Guest Access on Moodle Courses
3:26
Dr. Nellie Deutsch
Рет қаралды 8
Word Search - Backtracking - Leetcode 79 - Python
10:18
NeetCode
Рет қаралды 337 М.
Coin Change - Leetcode 322 - Dynamic Programming (Python)
15:27
Recursive Backtracking - DSA Course in Python Lecture 14
12:58
The Backtracking Blueprint: The Legendary 3 Keys To Backtracking Algorithms
13:44
Word Search - LeetCode 79 - Python (BACKTRACKING)
24:36
DEEPTI TALESRA
Рет қаралды 1,3 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 329 М.
Pacific Atlantic Water Flow - Leetcode 417 - Graphs (Python)
17:10
WORD SEARCH | LEETCODE 79 | PYTHON DFS SOLUTION
18:54
Cracking FAANG
Рет қаралды 3,8 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 438 М.
This Game Is Wild...
00:19
MrBeast
Рет қаралды 152 МЛН