Rotating the Box - Leetcode 1861 - Python

  Рет қаралды 5,546

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 13
@ducpham1378
@ducpham1378 13 сағат бұрын
Thank you NeetCode for being so consistent with your videos, I learned a lot from them 🙏 For this problem I propose a simpler solution: for each row - join the row into a string - split the string by "*" - for each element in the splitted list, sort it in reverse. This put "#" to the right of "." - re-join the strings Here's the code: class Solution: def rotateTheBox(self, box: List[List[str]]) -> List[List[str]]: res = [] for row in box: s = ''.join(row) lst = s.split('*') res.append('*'.join([''.join(sorted(x, reverse=True)) for x in lst])) return zip(*res[::-1])
@abhinavchoukse2357
@abhinavchoukse2357 14 сағат бұрын
This is similiar to the problem "283. Move all zeros to end" in this we just have to shift all empty spaces at first
@Сергей-е5э3н
@Сергей-е5э3н 6 сағат бұрын
Man, I really like your videos. You do a lot for us. Thank you for that! 😍
@visheshmangla8220
@visheshmangla8220 2 сағат бұрын
shortcut to 90 deg rot -> map(reversed, zip(*box))
@SergeyAngelov
@SergeyAngelov 4 сағат бұрын
Solved it using two pointers approach, but watched video anyway to support the channel. 👍
@marcoaraujo9446
@marcoaraujo9446 4 сағат бұрын
Neet, ty again for the good work. Keep going man ❤
@Nonsense116
@Nonsense116 20 сағат бұрын
No way! I literally solved this problem 2 minutes ago and went "I bet NC has a better solution than what I found, let me go check it out" only to find you uploaded 1 hour ago! Coming in clutch as always!
@prajwals8203
@prajwals8203 17 сағат бұрын
return zip(*box[::-1])
@pastori2672
@pastori2672 10 сағат бұрын
yeah that doesnt work m8
@leesinisbae8278
@leesinisbae8278 9 сағат бұрын
Learnt that in Advent Of Code last year, where there was an identical problem
@bhanunani1307
@bhanunani1307 17 сағат бұрын
bro please solve leetcode 493.Reverse Pairs
@robertbaindourov134
@robertbaindourov134 21 сағат бұрын
That makes me second!
@mrmani1700
@mrmani1700 21 сағат бұрын
First like❤
Rotating the Box | Leetcode 1861
11:28
Techdose
Рет қаралды 1,3 М.
When a 700 Elo starts cheating...
30:47
GothamChess
Рет қаралды 72 М.
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 166 МЛН
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 5 МЛН
Coding Pong in C from Scratch |  Scoring and Game Loop | Final Ep. 4
1:18:29
Count Unguarded Cells in the Grid - Leetcode 2257 - Python
17:14
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 147 М.
1861. Rotating the Box | Simulation | 2 Pointers
17:00
Aryan Mittal
Рет қаралды 758
Pytest Tutorial - How to Test Python Code
1:28:39
freeCodeCamp.org
Рет қаралды 217 М.