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])
@abhinavchoukse235715 сағат бұрын
This is similiar to the problem "283. Move all zeros to end" in this we just have to shift all empty spaces at first
@visheshmangla82202 сағат бұрын
shortcut to 90 deg rot -> map(reversed, zip(*box))
@Сергей-е5э3н6 сағат бұрын
Man, I really like your videos. You do a lot for us. Thank you for that! 😍
@SergeyAngelov4 сағат бұрын
Solved it using two pointers approach, but watched video anyway to support the channel. 👍
@marcoaraujo94465 сағат бұрын
Neet, ty again for the good work. Keep going man ❤
@prajwals820317 сағат бұрын
return zip(*box[::-1])
@pastori267210 сағат бұрын
yeah that doesnt work m8
@leesinisbae82789 сағат бұрын
Learnt that in Advent Of Code last year, where there was an identical problem
@Nonsense11620 сағат бұрын
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!