Rotating the Box - Leetcode 1861 - Python

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

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 13
@ducpham1378
@ducpham1378 14 сағат бұрын
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 15 сағат бұрын
This is similiar to the problem "283. Move all zeros to end" in this we just have to shift all empty spaces at first
@visheshmangla8220
@visheshmangla8220 2 сағат бұрын
shortcut to 90 deg rot -> map(reversed, zip(*box))
@Сергей-е5э3н
@Сергей-е5э3н 6 сағат бұрын
Man, I really like your videos. You do a lot for us. Thank you for that! 😍
@SergeyAngelov
@SergeyAngelov 4 сағат бұрын
Solved it using two pointers approach, but watched video anyway to support the channel. 👍
@marcoaraujo9446
@marcoaraujo9446 5 сағат бұрын
Neet, ty again for the good work. Keep going man ❤
@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
@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!
@bhanunani1307
@bhanunani1307 17 сағат бұрын
bro please solve leetcode 493.Reverse Pairs
@robertbaindourov134
@robertbaindourov134 21 сағат бұрын
That makes me second!
@mrmani1700
@mrmani1700 21 сағат бұрын
First like❤
Count Unguarded Cells in the Grid - Leetcode 2257 - Python
17:14
Stop using std::vector wrong
23:14
The Cherno
Рет қаралды 149 М.
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 51 МЛН
Don't underestimate anyone
00:47
奇軒Tricking
Рет қаралды 15 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 166 МЛН
Shortest Subarray with Sum at Least K - Leetcode 862 - Python
27:57
I regret doing this...
1:20:07
Tsoding Daily
Рет қаралды 85 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 577 М.
Why Didn't He Get the Job? Let's Find Out! // Code Review
27:25
The Cherno
Рет қаралды 148 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 183 М.
I tried Swift and came out a different person
1:56:59
Tsoding Daily
Рет қаралды 119 М.
Take K of Each Character From Left and Right - Leetcode - Python
17:19
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 293 М.
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 51 МЛН