REVERSE WORDS IN A STRING | LEETCODE 151 | PYTHON SOLUTION

  Рет қаралды 8,389

Cracking FAANG

Cracking FAANG

Күн бұрын

Пікірлер: 13
@dnm9931
@dnm9931 Ай бұрын
Guys it looks like ‘i-1’ isn’t needed, ,y solution passes all test cases when I submit it without that line! Thanks so much,Cush cracking faang for the vid! You probably see me commenting on all your vids now!
@arkachaudhuri7339
@arkachaudhuri7339 6 ай бұрын
Hey, Can someone explain the purpose for the i -= 1 after parsing the string builder? Shouldn't it anyway iterate forth to the next if it encounters a whitespace?
@elias043011
@elias043011 6 ай бұрын
He's moving it back WITHIN the if statement because after exiting the if conditional block, he adds to "i" again.. you could get around this by checking ahead in the nested while statement while i + 1 < len(s) and s[i + 1] != " ":
@kingfriizy5707
@kingfriizy5707 10 ай бұрын
its a medium because the follow up is solve in constant memory
@barybary42
@barybary42 5 ай бұрын
which is not that straightforward
@Ammar23217
@Ammar23217 Жыл бұрын
very good solution
@crackfaang
@crackfaang Жыл бұрын
Thanks mate, glad you found it helpful
@wentaogao1118
@wentaogao1118 2 жыл бұрын
Thanks., very nice solution
@crackfaang
@crackfaang 2 жыл бұрын
Thanks for the kind words! Make sure to subscribe so you don’t miss future videos
@pshi1989
@pshi1989 2 жыл бұрын
thank you 😊
@MohitJain-dt4nb
@MohitJain-dt4nb 5 ай бұрын
why can't we simply do this-: class Solution: def reverseWords(self, s: str) -> str: words = s.split() return ' '.join(reversed(words))
@GiaBìnhVũ-w4s
@GiaBìnhVũ-w4s 3 ай бұрын
yoooo that is much better, ty !!
@luuc
@luuc Ай бұрын
That's definitely one way to solve it. Though, the idea behind the question is to practice a specific competitive programming pattern (two-pointer). Can you solve it without any memory usage?
BASIC CALCULATOR | LEETCODE # 224 | PYTHON SOLUTION
21:06
Cracking FAANG
Рет қаралды 25 М.
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 8 МЛН
Don't underestimate anyone
00:47
奇軒Tricking
Рет қаралды 21 МЛН
Farmer narrowly escapes tiger attack
00:20
CTV News
Рет қаралды 11 МЛН
Reverse Words in a String | LeetCode 151 | C++, Java, Python
13:58
Knowledge Center
Рет қаралды 192 М.
How I Failed the Google Coding Interview (and lessons I learned)
14:24
Reverse String - 3 Ways - Leetcode 344 - Python
9:03
NeetCode
Рет қаралды 59 М.
⚡️NEWS | RUBLE COLLAPSE | STRIKE ON CRIMEA | PUTIN IN KAZAKHSTAN
10:34
Ходорковский LIVE
Рет қаралды 207 М.
Reverse Words in a String III - Leetcode 557 - Python
10:18
NeetCodeIO
Рет қаралды 18 М.
Argument Parsing with argparse in Python
11:27
NeuralNine
Рет қаралды 16 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 674 М.
I Regret Marrying Him ✅ Learn English Through Stories ✅
9:41
English Stories with Allicia 2
Рет қаралды 7 М.
String Compression - LeetCode 443 - Python #leetcode75 #leetcode
12:04
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 8 МЛН