Walking Robot Simulation - Leetcode 874 - Python

  Рет қаралды 10,356

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 29
@adilansari-hq9ge
@adilansari-hq9ge 2 ай бұрын
Dear Bro , please do not miss to upload daily challenge videos.
@intrepidski9417
@intrepidski9417 2 ай бұрын
for real, this guy is carrying me with his explanations
@greatfate
@greatfate 2 ай бұрын
another way to do 90 degree rotations if you like math is this: 90 degree clockwise: (x, y) -> (y, -x) 90 degree anticlockwise: (x, y) -> (-y, x)
@MP-ny3ep
@MP-ny3ep 2 ай бұрын
Great explanation as always. Missed you for a while there!
@abhishaiwinston9794
@abhishaiwinston9794 2 ай бұрын
I think a testcase has been missed in the code,when robot starts at 0,0 ,the case hasn't been accounted for in the code,a flag can be used to check if robot reaches 0,0 again and if it's in obstacles, first time flag=0 so no problem, second time flag=1 so break, leetcode hasn't made the testcase for this event
@nirmalgurjar8181
@nirmalgurjar8181 2 ай бұрын
You try to -1 from directions, then you realize if you already at 0 it will turn 0 to -1 means index out of bound, so you think to add length (+4) but again it can go out of bound if goes beyond length then you handle it by taking mode (%) of the length (4) so finally it comes to d = (d - 1 + 4) % 4 ~ d = (d + 3) % 4
@prajwals8203
@prajwals8203 2 ай бұрын
if ele == -1: cur_dir = cur_dir + 1 if cur_dir < 3 else 0 if ele == -2: cur_dir = cur_dir - 1 if cur_dir > 0 else 3 just roll the value to 0 or max(3) when you encounter out of bound
@vidhishah9154
@vidhishah9154 2 ай бұрын
Thank you for adding video solution.
@malvado8267
@malvado8267 2 ай бұрын
instead of (d-1)%4 , use (d+3)%4
@chiragverma5839
@chiragverma5839 2 ай бұрын
why?
@54-nileshparab96
@54-nileshparab96 2 ай бұрын
@@chiragverma5839 bcoz d=-1 might happen which is out of bound
@nirmalgurjar8181
@nirmalgurjar8181 2 ай бұрын
You try to -1 from directions, then you realize if you already at 0 it will turn 0 to -1 means index out of bound, so you think to add + 4 but again it can go out of bound if goes beyond length then you handle it by taking mode(%) so finally it comes to d = (d - 1 + 4) % 4 ~ d = (d + 3) % 4
@techy_ms-e2m
@techy_ms-e2m 2 ай бұрын
Thinks that java user needs
@ParodyCSEDept
@ParodyCSEDept 2 ай бұрын
A proper medium problem
@kcprxkln
@kcprxkln 2 ай бұрын
it it possible to implement obstacle detection just based on the movement? something like if the obstacle is placed between old and new x/y when the second coord is the same?
@AVIS_11
@AVIS_11 2 ай бұрын
Genuine question why can we directly check from the list given why we are using hash set
@mohamedasifar
@mohamedasifar 2 ай бұрын
This problem is nightmare for me 😶
@tharunkumar5095
@tharunkumar5095 2 ай бұрын
Question says, there might be obstacle at (0,0) So, what does that mean?? Robot can move on obstracle as well??
@rafik1968
@rafik1968 2 ай бұрын
yes he can move ... but if the instructions lead him again to (0,0) it won't access it and will stop one step before.Don't overthink about this edge case .it is not important in the logic .Try to use Hashmap and follow the instructions of the problem set...no tricks just the implementation
@tharunkumar5095
@tharunkumar5095 2 ай бұрын
@@rafik1968 Okay Thank you :-)
@badgamertreek6698
@badgamertreek6698 2 ай бұрын
Any neetcode discounts coming up?
@Apoorv2431
@Apoorv2431 2 ай бұрын
wow i mean wow what an explanation
@tariqelamin5847
@tariqelamin5847 2 ай бұрын
I dont understand how the model work in this problem
@VinayKumar-xs6el
@VinayKumar-xs6el 2 ай бұрын
GOAT
@prajwals8203
@prajwals8203 2 ай бұрын
took me a long time to realize moving north is not similar to moving up one row
@jegadheeswarank6290
@jegadheeswarank6290 2 ай бұрын
Smooth
@tariqelamin5847
@tariqelamin5847 2 ай бұрын
your the goat
@tariqelamin5847
@tariqelamin5847 2 ай бұрын
yooooooo I was just doing this problem
@prashantverma2325
@prashantverma2325 2 ай бұрын
(d-1)%4 is out of bound, should be used (d+3)%4
Find K-th Smallest Pair Distance - Leetcode 719 - Python
25:35
NeetCodeIO
Рет қаралды 15 М.
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 13 МЛН
LeetCode 874 - Walking Robot Simulation - Java
16:57
Alpha-Code
Рет қаралды 392
Integer to English Words - Leetcode 273 - Python
20:59
NeetCodeIO
Рет қаралды 15 М.
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 650 М.
Rabin Karp - Shortest Palindrome - Leetcode 214
22:07
NeetCodeIO
Рет қаралды 17 М.
The Value of Source Code
17:46
Philomatics
Рет қаралды 203 М.
What P vs NP is actually about
17:58
Polylog
Рет қаралды 134 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 731 М.
DHH discusses SQLite (and Stoicism)
54:00
Aaron Francis
Рет қаралды 100 М.
Ugly Number II - Leetcode 264 - Python
15:17
NeetCodeIO
Рет қаралды 15 М.
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 13 МЛН