- 336
- 67 023
hakunamatasq
Canada
เข้าร่วมเมื่อ 10 ก.ย. 2020
Solving LeetCode questions in Java with an explanation of the solution and analysis of the space-time complexity.
245. Shortest Word Distance III (LeetCode, Java)
Question 245 on LeetCode solved in Java with an explanation for Space and Time complexity
มุมมอง: 14
วีดีโอ
156. Binary Tree Upside Down (LeetCode, Java)
มุมมอง 28หลายเดือนก่อน
Question 156 on LeetCode solved in Java with an explanation for Space and Time Complexity
551. Student Attendance Record I (LeetCode, Java)
มุมมอง 7หลายเดือนก่อน
Question 551 on LeetCode solved in Java with an explanation for Space and Time Complexity
2064. Minimized Maximum of Products Distributed to Any Store (LeetCode, Java)
มุมมอง 222 หลายเดือนก่อน
Question 2064 on LeetCode solved in Java with an explanation for Space and Time Complexity
530. Minimum Absolute Difference in BST (LeetCode, Java)
มุมมอง 333 หลายเดือนก่อน
Question 530 on LeetCode solved in Java with an explanation for Space and Time Complexity
561. Array Partition (LeetCode, Java)
มุมมอง 294 หลายเดือนก่อน
Question 561 on LeetCode solved in Java with an explanation for Space and Time Complexity.
422. Valid Word Square (LeetCode, Java)
มุมมอง 544 หลายเดือนก่อน
Question 422 on LeetCode solved in Java with an explanation for Space and Time Complexity
592. Fraction Addition and Subtraction (LeetCode, Java)
มุมมอง 1225 หลายเดือนก่อน
Question 592 on LeetCode solved in Java with an explanation for Space and Time Complexity.
476. Number Complement (LeetCode, Java)
มุมมอง 95 หลายเดือนก่อน
Question 476 on LeetCode solved in Java with an explanation for Space and Time Complexity
506. Relative Ranks (LeetCode, Java)
มุมมอง 235 หลายเดือนก่อน
Question 506 on LeetCode solved in Java with an explanation for Space and Time Complexity.
501. Find Mode in Binary Search Tree (LeetCode, Java)
มุมมอง 105 หลายเดือนก่อน
Question 501 on LeetCode solved in Java with an explanation of Space and Time Complexity.
500. Keyboard Row (LeetCode, Java)
มุมมอง 165 หลายเดือนก่อน
Question 500 on LeetCode solved in Java with an explanation for Space and Time Complexity
492. Construct the Rectangle (LeetCode, Java)
มุมมอง 495 หลายเดือนก่อน
Question 492 on LeetCode solved in Java with an explantation for Space and Time Complexity.
455. Assign Cookies (LeetCode, Java)
มุมมอง 1225 หลายเดือนก่อน
Question 455 on LeetCode solved in Java with an explanation for Space and Time Complexity
414. Third Maximum Number (LeetCode, Java)
มุมมอง 4275 หลายเดือนก่อน
Question 414 on LeetCode solved in Java with an explanation for Space and Time Complexity
2053. Kth Distinct String in an Array (LeetCode, Java)
มุมมอง 185 หลายเดือนก่อน
2053. Kth Distinct String in an Array (LeetCode, Java)
1653. Minimum Deletions to Make String Balanced (LeetCode, Java)
มุมมอง 285 หลายเดือนก่อน
1653. Minimum Deletions to Make String Balanced (LeetCode, Java)
408. Valid Word Abbreviation (LeetCode, Java)
มุมมอง 495 หลายเดือนก่อน
408. Valid Word Abbreviation (LeetCode, Java)
1084. Sales Analysis III (LeetCode, SQL)
มุมมอง 595 หลายเดือนก่อน
1084. Sales Analysis III (LeetCode, SQL)
2976. Minimum Cost to Convert String I (LeetCode, Java)
มุมมอง 1185 หลายเดือนก่อน
2976. Minimum Cost to Convert String I (LeetCode, Java)
2191. Sort the Jumbled Numbers (LeetCode, Java)
มุมมอง 1175 หลายเดือนก่อน
2191. Sort the Jumbled Numbers (LeetCode, Java)
1636. Sort Array by Increasing Frequency (LeetCode, Java)
มุมมอง 1406 หลายเดือนก่อน
1636. Sort Array by Increasing Frequency (LeetCode, Java)
1380. Lucky Numbers in a Matrix (LeetCode, Java)
มุมมอง 586 หลายเดือนก่อน
1380. Lucky Numbers in a Matrix (LeetCode, Java)
1717. Maximum Score From Removing Substrings (LeetCode, Java)
มุมมอง 166 หลายเดือนก่อน
1717. Maximum Score From Removing Substrings (LeetCode, Java)
2196 Create Binary Tree From Descriptions (LeetCode, Java)
มุมมอง 126 หลายเดือนก่อน
2196 Create Binary Tree From Descriptions (LeetCode, Java)
1598. Crawler Log Folder (LeetCode, Java)
มุมมอง 106 หลายเดือนก่อน
1598. Crawler Log Folder (LeetCode, Java)
1701. Average Waiting Time (LeetCode, Java)
มุมมอง 286 หลายเดือนก่อน
1701. Average Waiting Time (LeetCode, Java)
1823. Find the Winner of the Circular Game (LeetCode, Java)
มุมมอง 116 หลายเดือนก่อน
1823. Find the Winner of the Circular Game (LeetCode, Java)
thank you!
Thank you for the video! Learned a lot, and your pacing is amazing! One question though, since we could be pushing n - 1 ancestors at the line 39 when our graph is just a list, shouldn't the time complexity be O(n^2 + m) -- Given that m is the size of the edges list, and we'd need to iterate over it to create the adjacency list -- ?
Very good 👍
in your note, T.C should be NLog N, Since we are sorting the array in the first place.
exlain the problem before you show how to solve
one of the best solutions so far <3
great
Minor thing: char is indeed a primitive type but char[] is an object. You don't need to use Character[] to make use of Arrays.sort(). Cool video though =)
Yaay let's go!
Huge fan of the consistent videos. Keep up the good work!!!🙌
Thanks for this.
Perfect explanation thank you
Love your solution. Thank you!
It's not obvious from the first sight what would one even need the backward mapping, they should've included that into examples. I just made a lookup through all entries of a single hashmap to look for a backward mapping. It's maximum size is constant I didn't have to worry about that lookup in terms of overall time/space compexity. But, I guess, keeping two hashmaps is more clear and obvious though.
"Promo sm"
very well expalined, Thank you
I am sure there is some gap in the test cases. Assume this Dictionary words - [abc, adc, aec] isUnique - adc The hash map will store - a1c -> "" So this will return false as per above code as empty string won't match the "adc" but this should return true as per question.
Thanks for the video. but how can I enable code auto-completion in leetcode like you do?
premium
This is awesome!
Why do we need HashMap in this solution?
why we used select max (num) ? How it's extra helping?
Your algo runs in linear time(o(n)) at the very least because in order for you to find the last index, you have to search almost the entire string in the worst case. Similar thing with substring, though before java 7 substring ran in constant time. So depending on the java version, this algo also takes an extra linear time cost. Also we don't need to check if the parent has a length of one as all we need to do is make sure our parent is not empty(as in we have a parent). So not empty or '... > 0' is also fine
Good explanation
It was a really challenging question and i went through the video twice to understand it but i request you to dry run few test cases before going to the approach so it would be even simpler to understand.
Subscribed!! Thanks for the amazing explanation
Could you make a playlist of imp sql queries asked in job interviews.
Well Explained...
So simple and effective, another easy way to do this would be SELECT name FROM ( SELECT ManagerID, name FROM Employee GROUP BY 1, 2 HAVING COUNT(*) >= 5)
AHA! I bet you didn't expect a comment.
bkl kch smjh nai aya
thank you maam
nicely solved
Hey, I think you should speak louder or add captions.
have to finish in O(N) !!
you're cool
so clean explanation. thanks!
Glad it was helpful!
I still don't understand 😭😭😭
Hello, which part exactly? I can try to help :)
@@hakunamatasq its just a bit overwhelming, i can't follow it.
wow
Good explainations!...
Please upload more of these
you could just find the sum of the AP and subtract the sum of the array elements..
Clean code😊
thanks for actually jumping right into the problem instead of spending the first half explaining what the problem is lol
Can we do better than O(N^2) time complexity?
Really Nice
could you kindly clarify why we need the min = Integer.MAX_VALUE defined on line 9 Also, kindly explain what line 20 does
min = Integer.MAX_VALUE - It's just a value for initialization, which won't be a real result of this program (could be even -1 as we are doing Math.abs there). Line 20 calculates the difference between indexes pointing to word1 and word2 which can be a positive or negative value, depends on the position of the words (that's why You use Math.abs to return positive integer) and You pick minimum value between min = Integer.MAX_VALUE and the result of the Math.abs as Your result.
The Voice is So low
Actually this is not O(n) time. If you are going only to the left/right of one tree, then it is O(n), if you are going through both of them, basically you are checking each node against all nodes in another tree. - Better way is to consider this just as a tree instead of a BST - Build hashset for 1st tree. - Traverse 2nd tree and look for map[target - node->val]. O(m+n) time O(m) space
so clear, thank you for making this video and explain the minus n!