[Java] Leetcode 1041. Robot Bounded In Circle [Array #10]

  Рет қаралды 3,298

Eric Programming

Eric Programming

Күн бұрын

Пікірлер: 2
@hyonsokna7244
@hyonsokna7244 2 жыл бұрын
thank you so much! very clear and easy solution!
@jeroenvandenheuvel3869
@jeroenvandenheuvel3869 2 жыл бұрын
Thanks for the explanation! Although this solution works well it's a bit more complex than necessary. What about using cosine and sine? ``` x = 0 y = 0 rotation = 0 for instruction in instructions: if instruction == "L": rotation += 270 rotation = rotation % 360 elif instruction == "R": rotation += 90 rotation = rotation % 360 else: y -= int(math.cos(math.radians(rotation))) x += int(math.sin(math.radians(rotation))) if x == 0 and y == 0: return True elif rotation != 0: return True return False ``` Or without these functions the movement can be done like this: ``` if rotation % 180 == 0: y += (rotation / 90) - 1 else: x -= (rotation / 90) - 2 ```
[Java] Leetcode 31. Next Permutation [Array #11]
11:58
Eric Programming
Рет қаралды 3 М.
PEDRO PEDRO INSIDEOUT
00:10
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 27 МЛН
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 47 МЛН
ДОКАЗАЛ ЧТО НЕ КАБЛУК #shorts
00:30
Паша Осадчий
Рет қаралды 1,5 МЛН
Leetcode - Robot Bounded In Circle (Python)
8:02
Timothy H Chang
Рет қаралды 2,7 М.
Cursor Is Beating VS Code (...by forking it)
18:00
Theo - t3․gg
Рет қаралды 18 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 279 М.
[Java] Leetcode 489. Robot Room Cleaner [Backtracking #14]
14:10
Eric Programming
Рет қаралды 6 М.
Advice from the Top 1% of Software Engineers
10:21
Kevin Naughton Jr.
Рет қаралды 3,3 МЛН
Coding Was HARD Until I Learned These 5 Things...
8:34
Elsa Scola
Рет қаралды 373 М.
[Java] Leetcode 343. Integer Break [DP Integer Partition #1]
13:58
Eric Programming
Рет қаралды 3,9 М.
PEDRO PEDRO INSIDEOUT
00:10
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 27 МЛН