No video

Winning LeetCode Weekly Contest 174 + Explanations

  Рет қаралды 3,449

William Lin

William Lin

4 жыл бұрын

My first win on LeetCode! Anyways, explanations start at 14:05. If they are a bit unclear, feel free to ask questions in the comments below so that I can improve!
Bonus: I challenge everyone to solve the last problem in O(n), as opposed to the O(n^2) solutions most people had. Comment your solution in the description!
If this video was helpful, be sure to like & subscribe!

Пікірлер: 18
@rogernadal9106
@rogernadal9106 4 жыл бұрын
Amazing, Congratulation William! You can save more time by running multiple tests in one go. You just have to paste the i'th test after (i-1)th test in the custom test section. Give it a try and it may save you couple more mins.
@tmwilliamlin168
@tmwilliamlin168 4 жыл бұрын
Wow, thanks! I never knew about that.
@premierdota9128
@premierdota9128 4 жыл бұрын
Congrats William! I wish I couldve done the third and fourth problem too. Will keep trying!
@bensonyuan5083
@bensonyuan5083 4 жыл бұрын
dude this is awesome! Looking forward to this weekly~
@bharathateja2797
@bharathateja2797 4 жыл бұрын
Excellent . I was using topological sort to find longest path in DAG . Now i learnt 2nd method using simple dfs by watching your video . Thank u so much.
@rohithgupta9672
@rohithgupta9672 4 жыл бұрын
Thanks lin
@saikat93ify
@saikat93ify 4 жыл бұрын
Congratulations on Winning your first LeetCode Contest, William ! Although this surprises me as I thought you had already won many. May you win many more in the future and May God Bless You. May I ask a question for C ? Here was my approach - We want to maximise (S1.S2) where S1 + S2 = S, the sum is invariant. Now, if the sum of S1 and S2 is invariant. The largest sum is when |S1 - S2| is as small as possible. I tried each edge and examined the difference between S1 and S2 and took the values where |S1 - S2| is the minimum possible. I thought taking the products directly would overflow and if we take the products mod M = 10^9 + 7, it might not be accurate. For example 10^9 + 9 > 5 but 10^9 + 9 (Mod M) < 5 (Mod M) Can you please explain how you avoided overflow ?
@tmwilliamlin168
@tmwilliamlin168 4 жыл бұрын
I used long longs and only took the answer modulo M when returning the final answer.
@saikat93ify
@saikat93ify 4 жыл бұрын
William Lin Will the product always fit in 64 bits ?
@tmwilliamlin168
@tmwilliamlin168 4 жыл бұрын
Yes, according to the constraints, S1+S2
@saikat93ify
@saikat93ify 4 жыл бұрын
@@tmwilliamlin168 Thanks !
@bhaskarbhasku2921
@bhaskarbhasku2921 4 жыл бұрын
does make_pair have more complexity than array stl?
@tmwilliamlin168
@tmwilliamlin168 4 жыл бұрын
They both work in constant time (if you mean time complexity). I'm not sure which one is faster, but they are both fast enough that it will not matter in most cases. I use array because, for example, you can make triples easily by writing array.
@bhaskarbhasku2921
@bhaskarbhasku2921 4 жыл бұрын
:)
@codeWithBatta
@codeWithBatta 4 жыл бұрын
Sir if you only make vedios of questions you solve only explaining ... It will be of great help. :)
@codeWithBatta
@codeWithBatta 4 жыл бұрын
Like you just explain the code of what you have done in questions of recent educational round at codeforces .. you can open your code and explain your logic .. about 1-3 minutes per question maybe
@tmwilliamlin168
@tmwilliamlin168 4 жыл бұрын
I plan to give explanations for cf educational rounds as well, but just after I finish solving all of the problems.
@AlexWice
@AlexWice 4 жыл бұрын
Nice screencast and congrats on 1st. Would you like to join the coding interview community at interview.solutions/ ? There's a decent audience to showcase your explanations there.
LeetCode Biweekly Contest 19 (2nd) + Explanations
21:27
William Lin
Рет қаралды 1,4 М.
Winning LeetCode Weekly Contest 198
40:27
William Lin
Рет қаралды 111 М.
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 7 МЛН
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 57 МЛН
小蚂蚁被感动了!火影忍者 #佐助 #家庭
00:54
火影忍者一家
Рет қаралды 45 МЛН
Winning Codeforces Round #663 (Div. 2)
46:18
William Lin
Рет қаралды 96 М.
Grumpy Bookstore Owner - Leetcode 1052 - Python
7:58
NeetCodeIO
Рет қаралды 10 М.
Facebook Hacker Cup Qualification Round 2020 + Explanations
1:22:35
William Lin
Рет қаралды 418 М.
My Brain after 569 Leetcode Problems
7:50
NeetCode
Рет қаралды 2,5 МЛН
LeetCode Biweekly Contest 30 (2nd)
12:50
William Lin
Рет қаралды 53 М.
Top 10 Javascript Algorithms to Prepare for Coding Interviews
1:52:53
freeCodeCamp.org
Рет қаралды 66 М.
30-Day LeetCoding Challenge Speedrun (1:00:38.53)
1:07:26
William Lin
Рет қаралды 114 М.
Winning Leetcode Weekly Contest 323
22:18
Joshua Chen
Рет қаралды 3,4 М.
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 601 М.
Winning LeetCode Weekly Contest 201
12:07
William Lin
Рет қаралды 129 М.
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 7 МЛН