CS Robot
CS Robot
  • 14
  • 30 578
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
มุมมอง: 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...

ความคิดเห็น

  • @eolookwawa
    @eolookwawa 3 วันที่ผ่านมา

    This is the best quick select explanation indeed. Other videos never explain what each element of the code actually means.

  • @Prenevyspam
    @Prenevyspam 10 วันที่ผ่านมา

    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!

  • @SangriaSarah
    @SangriaSarah หลายเดือนก่อน

    Fantastic explanation. Very clear and concise and thorough. Thank you!

  • @lunchbox1553
    @lunchbox1553 2 หลายเดือนก่อน

    Shouldn't the time complexity be denoted big theta of n and big O of n^2?

  • @דבירגיל
    @דבירגיל 2 หลายเดือนก่อน

    brilliant. One of the best algorithm explanations here. fine work thank you!

  • @mvkful
    @mvkful 2 หลายเดือนก่อน

    Perfect explanation! Thank you

  • @LavanVivekanandasarma
    @LavanVivekanandasarma 2 หลายเดือนก่อน

    This is an unbelievably concise yet helpful explanation - thanks a ton

  • @pikachupika7203
    @pikachupika7203 2 หลายเดือนก่อน

    best video ever for quickselect

  • @JikeWimblik
    @JikeWimblik 3 หลายเดือนก่อน

    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.

  • @rajsriselvansrp4831
    @rajsriselvansrp4831 3 หลายเดือนก่อน

    Good work!

  • @COURATWENTYTHREE
    @COURATWENTYTHREE 3 หลายเดือนก่อน

    Best Quick Sort explaination❤❤❤❤

  • @shauryatomer1058
    @shauryatomer1058 3 หลายเดือนก่อน

    Man you make such great videos, why'd you stop?

  • @priyanshkumar17
    @priyanshkumar17 5 หลายเดือนก่อน

    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; } };

  • @SIMAR_SINGH_RAYAT
    @SIMAR_SINGH_RAYAT 5 หลายเดือนก่อน

    Wrong solution

  • @ChillWithAbhishek
    @ChillWithAbhishek 5 หลายเดือนก่อน

    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.

  • @godofpeak1240
    @godofpeak1240 5 หลายเดือนก่อน

    You easily had the best video on it, thank you!

  • @neev4n
    @neev4n 5 หลายเดือนก่อน

    brother you need more views you are saving my algorithms exam fr

  • @neev4n
    @neev4n 5 หลายเดือนก่อน

    lowkey the best quickselect explanation ever what

  • @judowithkeishin
    @judowithkeishin 6 หลายเดือนก่อน

    The time complexity is wrong, its o(n^2) worst case if you select the largest or smallest element in the array

  • @jnayehsirine6222
    @jnayehsirine6222 6 หลายเดือนก่อน

    great video , it deserves more views

  • @aliramazani2024
    @aliramazani2024 6 หลายเดือนก่อน

    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!

    • @lunchbox1553
      @lunchbox1553 2 หลายเดือนก่อน

      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.

  • @apbh
    @apbh 7 หลายเดือนก่อน

    Isn't the third largest element 10 here?

  • @Nishit_369
    @Nishit_369 7 หลายเดือนก่อน

    Awesome explanation. Thanks!!!

  • @mariuszpudzianowski7475
    @mariuszpudzianowski7475 8 หลายเดือนก่อน

    great explanation

  • @juancarlosvillanuevaquiros6763
    @juancarlosvillanuevaquiros6763 8 หลายเดือนก่อน

    Super good explanation video. This deserves more views

  • @eriklee1131
    @eriklee1131 9 หลายเดือนก่อน

    great video!

  • @akashkadam2741
    @akashkadam2741 9 หลายเดือนก่อน

    your videos are really intuitive and easy to understand, you should keep posting!!!

  • @akashkadam2741
    @akashkadam2741 9 หลายเดือนก่อน

    really well explained

  • @ahmedabdelalem4326
    @ahmedabdelalem4326 9 หลายเดือนก่อน

    this is the first time i can understand algorithms from the first time.

  • @bouzie8000
    @bouzie8000 9 หลายเดือนก่อน

    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

  • @kurtlarsen8270
    @kurtlarsen8270 10 หลายเดือนก่อน

    good explanation, thanks

  • @saisardesai5548
    @saisardesai5548 10 หลายเดือนก่อน

    straight to the point and no nonse explaination!, thanks for explaining the partition function now I can easily remember the solution

  • @kevinthant2952
    @kevinthant2952 11 หลายเดือนก่อน

    Very good explanation, thank you!

  • @beik118
    @beik118 ปีที่แล้ว

    really really good video

  • @arandomcoder101
    @arandomcoder101 ปีที่แล้ว

    How do you make these graphics ? Is it a presentation ? Slides , or something like manim ?

  • @AbhijeetMishra-bl7yr
    @AbhijeetMishra-bl7yr ปีที่แล้ว

    Keep posting these king of videos Great usage of example and step by step impl explanation. Keeping it simple

  • @AbhijeetMishra-bl7yr
    @AbhijeetMishra-bl7yr ปีที่แล้ว

    This is best as far as I have seen on YT I was really stuck at I and J pointer. nailed it 🔥

  • @StephaneArcher
    @StephaneArcher ปีที่แล้ว

    Great explanation, thank you

  • @surters
    @surters ปีที่แล้ว

    Selecting the last as pivot is risky, selecting a random is much better.

    • @Fran-kc2gu
      @Fran-kc2gu ปีที่แล้ว

      lol no, if the order it's random which almost always is it's the same

    • @surters
      @surters ปีที่แล้ว

      @@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.

    • @alexandrch1758
      @alexandrch1758 10 หลายเดือนก่อน

      how can we adopt the partition function to select a random pivot? Just pivot = arr[randint(l, r)] doesn't work

    • @JimBob1937
      @JimBob1937 7 หลายเดือนก่อน

      @@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.

    • @surters
      @surters 7 หลายเดือนก่อน

      @@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.

  • @boojo3
    @boojo3 ปีที่แล้ว

    thank you so much this helped me understand very quickly <3 please post more content

  • @MrJ3
    @MrJ3 ปีที่แล้ว

    What a great, down to earth explanation.

  • @DK-ox7ze
    @DK-ox7ze ปีที่แล้ว

    In line 12 of your code, how's it guaranteed that newValue will be at max only one less than nums[i-1]?

    • @luvgohel4602
      @luvgohel4602 5 หลายเดือนก่อน

      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 😊

  • @alibozkurt7767
    @alibozkurt7767 ปีที่แล้ว

    thanks

  • @Sha-256-rath
    @Sha-256-rath ปีที่แล้ว

    really appreciate your way of explaining😇😇

  • @balapradeepkumarm5206
    @balapradeepkumarm5206 ปีที่แล้ว

    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

  • @andrewknyazkov6877
    @andrewknyazkov6877 ปีที่แล้ว

    thank you so much. that was a great explanation

  • @knowsbetter4113
    @knowsbetter4113 ปีที่แล้ว

    Love from india

  • @attafriski5901
    @attafriski5901 ปีที่แล้ว

    You have good explanation, Thanks it's help me a lot

  • @middleagedprogrammer-hl6oz
    @middleagedprogrammer-hl6oz ปีที่แล้ว

    Really good explanation!

  • @andrii5054
    @andrii5054 ปีที่แล้ว

    Great Explanation, thank you