- 14
- 30 578
CS Robot
Singapore
เข้าร่วมเมื่อ 10 ก.ย. 2022
Leetcode 718. Maximum Length of Repeated Subarray
In this video, I go through the approach and code implementation to solve leetcode number 718 maximum length of repeated subarray.
Reminders:
Play at a faster speed to learn faster
Turn on captions
Reminders:
Play at a faster speed to learn faster
Turn on captions
มุมมอง: 695
วีดีโอ
Leetcode 945. Minimum Increment to Make Array Unique
มุมมอง 6K2 ปีที่แล้ว
In this video, I will explain 2 approaches to solve Minimum Increment to Make Array Unique. I actually got this question in an online assessment so it will be good to learn the approach to this question. Reminders: Play at faster speed for faster learning Turn on auto generated captions
Leetcode 1335. Minimum Difficulty of a job Schedule (Dynamic Programming and Memoization)
มุมมอง 1112 ปีที่แล้ว
In this video I will walk you through the approach and the code to solve Minimum Difficulty of a Job Schedule. This is a hard dynamic programming question and I will show you the memoization approach. Reminders: Speed up the video to learn faster Turn on auto-generated captions
Understand Quick Sort (In 15 min)
มุมมอง 2382 ปีที่แล้ว
This video will help you understand one of the most popular sorting algorithms which is quick sort. Do remember to play at a faster speed and turn on captions for faster learning.
Understand Partition (In 8 mins)
มุมมอง 1382 ปีที่แล้ว
Understanding the partition algorithm is extremely crucial to implementing more complex algorithms that relies on it, such as quick select and quick sort. In this video, I carefully trace through the partition algorithm to make sure you guys really know what exactly is happening at every point in the algorithm. Do remember to play the video at a speed faster than 1x speed and turn on subtitles ...
Functions - Python Basics for Beginners
มุมมอง 122 ปีที่แล้ว
Learn all about python functions in this video! Functions are important to understand well as they are basically used in every application. Do remember to play at a speed faster than 1x speed and turn on captions for better learning.
Understand Quick Select (In 10 mins)
มุมมอง 23K2 ปีที่แล้ว
It is easy to understand how quick select works, but the partition algorithm is tough to reformulate especially in conditions such as technical interviews. This video will hopefully help you understand how quick select and partition really works so you will never need to memorise this algorithm again.
Dictionary - Python Basics for Beginners
มุมมอง 172 ปีที่แล้ว
Dictionaries are the most popular data structure in Computer Science, so it is important to understand them and learn them well. This video dives in the basics of using a dictionary. Remember to play the video at x1.25 speed or more for faster learning
Tuples and Lists - Python Basics for Beginners
มุมมอง 152 ปีที่แล้ว
Tuples and Lists are an essential data structure to learn in Python as it is used in basically all applications. This video dives into the differences between tuples and lists and explores the functionalities of lists intro 00:00 tuples and list common functionalities 02:12 ways to modify list 07:17 common mistake with list 12:40 SUBSCRIBE 14:42
For Loops and While Loops - Python Basics for Beginner
มุมมอง 232 ปีที่แล้ว
Loops are essential in many of our everyday applications so it is essential to master the concepts of loops. In this video, I trace through several examples in order to help you understand loops better. I recommend you to turn on captions and speed up the video in order to learn faster. intro 00:00 loops in everyday applications 00:04 for loops 00:47 while loops 03:02 continue keyword 06:31 bre...
If Elif Else - Python Basics for Beginners
มุมมอง 72 ปีที่แล้ว
Use If Elif Else statements to add more logic to your program. It is crucial to understand if elif and else as basically every program will include this programming construct. It is recommended to play this video at more than x1 speed for faster learning. If you like this video and wish to see more, don't forget to drop a like, comment and subscribe for more programming content. intro 00:00 if ...
Operators - Python Basics for Beginners
มุมมอง 252 ปีที่แล้ว
It is essential to understand what operators are, what function they hold in programming as well as the types of operators that exist. This video builds upon the previous videos on variables to show how variables or values can be combined using operators to produce something more meaningful. intro 00:00 what are operators? 00:06 arithmetic operators 00:25 comparison operators 00:52 logical oper...
Primitive Data Types - Python Basics for Beginners
มุมมอง 1232 ปีที่แล้ว
A follow up from the Variables video. Each and every value in a variable will have a data type, so it is essential to understand what a data type is. In this video, we delve deeper into the primitive data types of Python. Note that there is a mistake in the slides at 07:47 in the second example, it gets updated when going through the example. I advice you to turn on auto-generated subtitles and...
Variables - Python Basics for Beginners
มุมมอง 362 ปีที่แล้ว
Variables are the building blocks of programming. It is essential to master the concepts in this video before learning other more advanced concepts as everything builds from this. intro 00:00 print() 00:11 comments 01:00 what is a variable 01:40 assigning variables 01:58 reassigning variables 02:34 precision of variable naming 02:58 variable naming rules in python 03:18 multi word variable name...
This is the best quick select explanation indeed. Other videos never explain what each element of the code actually means.
I was so scared of quickselect before this video, thank you so much for breaking it down in the most understandable way. You're a great tutor!
Fantastic explanation. Very clear and concise and thorough. Thank you!
Shouldn't the time complexity be denoted big theta of n and big O of n^2?
brilliant. One of the best algorithm explanations here. fine work thank you!
Perfect explanation! Thank you
This is an unbelievably concise yet helpful explanation - thanks a ton
best video ever for quickselect
Fill the empty cells in the rows with their basic possibilities given the numbers in the sub grid row and column no need to do any more working out. Now go from left to right or right to left ignore the data in your cell and see what numbers ain't covered by the possibilities in the other cells or the cells already solved. If there are no possibilities deduced move to the next empty cell and wipe the info in the cell you just tested. If you do find a possible number or 2 from this test then the solution is that number or is one of those numbers. It's a very quick O n time test that trips the game of sudoku up and ruins it for everyone.
Good work!
Best Quick Sort explaination❤❤❤❤
Man you make such great videos, why'd you stop?
Initially, I thought of using Next Greater to Left & Next Greater to Right concepts, & did dry run as per below written code for the test cases, [1,2,2], [3,2,1,2,1,7] & [4,4,4,4,4]. According to the dry run, I got the correct answers, but when I run the test cases on leetcode, I get correct output for [1,2,2], but for [3,2,1,2,1,7] & [4,4,4,4,4], it shows output of 4, which is wrong. My dry run (as per the same code) yielded correct answer, but on running on platform, it fails. Can anyone help me address this issue ? The code is : class Solution { private: vector<int> NGR(vector<int>& arr, int n){ stack<int> st; vector<int> result(n, -1); for (int i = n - 1; i >= 0; i--) { while (!st.empty() && st.top() <= arr[i]) { st.pop(); } if (!st.empty()) { result[i] = st.top(); } st.push(arr[i]); } return result; } vector<int> NGL(vector<int>& arr, int n){ stack<int> st; vector<int> result(n, -1); for (int i = 0; i < n; i++) { while (!st.empty() && st.top() <= arr[i]) { st.pop(); } if (!st.empty()) { result[i] = st.top(); } st.push(arr[i]); } return result; } public: int minIncrementForUnique(vector<int>& nums) { int n = nums.size(); vector<int> ngr = NGR(nums, n); vector<int> ngl = NGL(nums, n); set<int> st; int minMoves = 0; for(int i = 0; i < n; i++){ int num = nums[i]; if(st.find(num) == st.end()) st.insert(num); else{ int gRight = ngr[i]; int gLeft = ngl[i]; // 4 cases // case - 1 if(gRight == -1 && gLeft == -1){ minMoves++; num++; } // case - 2 else if(min(gRight, gLeft) == -1){ minMoves += max(gRight, gLeft) + 1 - num; num = max(gRight, gLeft) + 1; } // case - 3 & 4 else if(min(gRight, gLeft) != -1){ int diff = abs(gRight - gLeft); if(diff > 1){ minMoves += min(gRight, gLeft) + 1 - num; num = min(gRight, gLeft) + 1; } else if(diff == 1){ minMoves += max(gRight, gLeft) + 1 - num; num = max(gRight, gLeft) + 1; } } } } return minMoves; } };
Wrong solution
One of the better explanations out there. The thing with partition is that there are various ways to do it and so many nuances with the boundary conditions if you are not careful. There is another method using while loops which I have always found tad bit more difficult. This one is more straightforward.
You easily had the best video on it, thank you!
brother you need more views you are saving my algorithms exam fr
lowkey the best quickselect explanation ever what
The time complexity is wrong, its o(n^2) worst case if you select the largest or smallest element in the array
great video , it deserves more views
I can say this video is the best explanation of the quick select algorithm on TH-cam. I read an article on GeeksforGeeks and only found myself more confused because of poor variable naming such as x and y, and weird way of partitioning like right - left, and so on. The method in this video and the explanation make more sense! Thanks CS Robot!
Never go to geeksforgeeks. It is by far the worst resource on the Internet because none of the articles are reviewed and you don't need any credentials to write one.
Isn't the third largest element 10 here?
Awesome explanation. Thanks!!!
great explanation
Super good explanation video. This deserves more views
great video!
your videos are really intuitive and easy to understand, you should keep posting!!!
really well explained
this is the first time i can understand algorithms from the first time.
Believe it or not, this is the best quick select explanation on youtube.For the first timein my life, i can write this algorithm without memorization
good explanation, thanks
straight to the point and no nonse explaination!, thanks for explaining the partition function now I can easily remember the solution
Very good explanation, thank you!
really really good video
How do you make these graphics ? Is it a presentation ? Slides , or something like manim ?
Keep posting these king of videos Great usage of example and step by step impl explanation. Keeping it simple
This is best as far as I have seen on YT I was really stuck at I and J pointer. nailed it 🔥
Great explanation, thank you
Selecting the last as pivot is risky, selecting a random is much better.
lol no, if the order it's random which almost always is it's the same
@@Fran-kc2gu Depend on the input as you say, but you hit the worst case O(N^2) if the list if already sorted, which is a denial of service attack vector. If your having a critical timeout you must meet you should even go with a median-of-medians.
how can we adopt the partition function to select a random pivot? Just pivot = arr[randint(l, r)] doesn't work
@@surters , if your list is unsorted, arguably list.length - 1 slot will follow a random distribution. Your worst case depends not only on the list but the kth position you're trying to find. It is true, a random selection can reduce worst case chance still, but it really is something you should judge on your use case. Your real world distribution of your list may not hit the worst case scenario as often as other distributions. If your list is small, your usage of random may actually incur more overhead than just selecting a fixed pivot. Don't let big O complexity blind you to the underlying complexity and overhead of the functions you call in your algorithms, or that the complexity depends on external factors to the algorithm, like the expected distribution of your list. For a DOS attack, your user would have to control the list and search position and the specific implementation would need to affect the shared resources appreciably. Your advice thus is highly specific to a very specific use case and implementation that isn't broadly of concern.
@@JimBob1937 If it is OK that sometimes O(N^2) is acceptable and the data is not depending on potential hostile 3rd party input, it could be OK. If your dealing with potentially hostile 3rd party inputs, depending on a predictable pivot is not advisable, picking a random pivot might be good enough. If on the other hand you can never afford to hit O(N^2) ever, then median of medians is an option. There is tons of literature on the matter.
thank you so much this helped me understand very quickly <3 please post more content
What a great, down to earth explanation.
In line 12 of your code, how's it guaranteed that newValue will be at max only one less than nums[i-1]?
Becuz we have sorted array & increment nums(i-1) value that's why nums(i-1) is greater than or equal current nums(I) value 😊
thanks
really appreciate your way of explaining😇😇
Is this works if the last element in an array is the largest?, bcoz the arr[i] and arr[r] swaps at the end of the each iteration right
thank you so much. that was a great explanation
Love from india
You have good explanation, Thanks it's help me a lot
Really good explanation!
Great Explanation, thank you