VALID WORD ABBREVIATION | LEETCODE # 408 | PYTHON TWO POINTERS SOLUTION

  Рет қаралды 11,146

Cracking FAANG

Cracking FAANG

Күн бұрын

Пікірлер: 25
@ReleaseTheKraken25
@ReleaseTheKraken25 Ай бұрын
Starting my meta tagged journey. I'm all in, if I get the job, I'm coming back to thank you.
@omarllama
@omarllama 19 күн бұрын
I got this today at Meta interview.
@OREdwardsJR
@OREdwardsJR 10 ай бұрын
> IDK who graded this on leetcode but I think they're wrong.. Yes, I agree lol. Conceptually, it's easier but it's still tricky enough to be medium. Thanks for the clear explanation!
@akshayakumar9365
@akshayakumar9365 Жыл бұрын
Thanks for the explanation!! Should we not have an extra check "if word_ptr >= len(word) return false" after the words_ptr=steps? because what if abbr had a greater step value than the whole word?
@AustinAtchley
@AustinAtchley 11 ай бұрын
It's covered by the while condition
@ainsdale7752
@ainsdale7752 2 жыл бұрын
Please could you explain the code on line 13 : "steps *10" ....why 10?
@namratasukanya8424
@namratasukanya8424 2 жыл бұрын
we want to get 12 together and not just 1 and 2 separately(abbr='i12iz4n'). Like in ex- word='internationalization', abbr='i12iz4n'
@izekoreric1310
@izekoreric1310 10 ай бұрын
I know it's been a year lol! But this is for anybody in the future. Line 13 is used to get a sequence of digits from a string. the steps * 10 creates a space for the next number in the sequence and + int(abbr[abbr_ptr]) adds the next number in the squence. for example: at first steps is 0 and int(abbr[abbr_ptr]) is 1 -> 0 * 10 is 0 then + 1 = 1 (first number in the sequence) next steps is 1 and int(abbr[abbr_ptr]) is 2 -> 1 * 10 is 10 (so the zero at the end creates the space for the next number in the sequence) then + 2 = 12. I hope this helps and I have not over complicate things lol!
@huachen9747
@huachen9747 10 ай бұрын
@@izekoreric1310thank you! This helped me
@CompulsiveProgrammerLear-qm6hj
@CompulsiveProgrammerLear-qm6hj 3 ай бұрын
​@@izekoreric1310 Indeed, it's basically the same than let numStr = ''; while (abbrIndex < abbr.length && !isNaN(abbr[abbrIndex])) { numStr += abbr[abbrIndex]; abbrIndex++; } let num = parseInt(numStr); BUT, that code approach is less memory efficient than the loop and accumulation approach (num = num * 10 + parseInt(abbr[abbrIndex])
@krishanakhatri4603
@krishanakhatri4603 7 ай бұрын
Crystal Clear Explanation!! 🖤
@aribasiebel
@aribasiebel Жыл бұрын
Subscribed after watching this soln. Great job!
@crackfaang
@crackfaang Жыл бұрын
Thanks! Welcome to the channel
@dystopianNinja1289
@dystopianNinja1289 Жыл бұрын
Same lol! this guy needs more exposure.
@solar679
@solar679 2 жыл бұрын
Please explain line 13
@aribasiebel
@aribasiebel Жыл бұрын
"123" => 123 at each iteration you need to multiply the 'sum' by 10 so you will get 0*10 + int(1) => 1*10 + int(2) => 12*10 + int(3)
@sarayarmohammadi3376
@sarayarmohammadi3376 Ай бұрын
Thank you
@subee128
@subee128 10 ай бұрын
Thanks
@Aureole62
@Aureole62 9 ай бұрын
I think there is an error on line 9. It should be: if int(abbr[abbr_ptr]) == 0: instead of if abbr[abbr_ptr] == 0:
@Ankit-hs9nb
@Ankit-hs9nb 2 жыл бұрын
the time complexity would be O(nlogn)? can you please explain how time complexity is O(n)?
@crackfaang
@crackfaang 2 жыл бұрын
It can’t be nlogn, there’s no log n portion here. The o(n) because in the worst case the word and the abbreviation are the same word (ie no abbreviations). Here you need to check every single character one by one to determine they are the same
@Ankit-hs9nb
@Ankit-hs9nb 2 жыл бұрын
Got it! Thanks! Recently found your channel and it is very helpful!
@AmolGautam
@AmolGautam Жыл бұрын
The test cases have been changed now , so this solution no longer works. I still like the approach to the solution.
@3rd_iimpact
@3rd_iimpact Жыл бұрын
Worked for me.
@ed2023bc
@ed2023bc 5 ай бұрын
Too fast. Not everybody has solved it for 56 times and now is bored with it.
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 8 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 695 М.
DOT PRODUCT OF TWO SPARSE VECTORS - 3 SOLUTIONS EXPLAINED [PYTHON]
31:06
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 124 М.
Data Analysis with Python for Excel Users - Full Course
3:57:46
freeCodeCamp.org
Рет қаралды 3,3 МЛН
VALID NUMBER | LEETCODE #65 | PYTHON SOLUTION
18:18
Cracking FAANG
Рет қаралды 6 М.
LOWEST COMMON ANCESTOR OF A BINARY TREE III [PYTHON]
16:38
Cracking FAANG
Рет қаралды 12 М.