CS Robot
CS Robot
  • 14
  • 23 276
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
zhlédnutí: 500

Video

Leetcode 945. Minimum Increment to Make Array Unique
zhlédnutí 6KPřed rokem
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)
zhlédnutí 101Před rokem
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)
zhlédnutí 172Před rokem
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)
zhlédnutí 119Před rokem
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
zhlédnutí 11Před rokem
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)
zhlédnutí 17KPřed rokem
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
zhlédnutí 17Před rokem
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
zhlédnutí 15Před rokem
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
zhlédnutí 20Před rokem
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
zhlédnutí 5Před rokem
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
zhlédnutí 19Před rokem
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
zhlédnutí 101Před rokem
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
zhlédnutí 33Před rokem
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...

Komentáře

  • @pikachupika7203
    @pikachupika7203 Před 5 dny

    best video ever for quickselect

  • @user-il9vr9oe7b
    @user-il9vr9oe7b Před 6 dny

    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 Před 17 dny

    Good work!

  • @COURATWENTYTHREE
    @COURATWENTYTHREE Před 22 dny

    Best Quick Sort explaination❤❤❤❤

  • @shauryatomer1058
    @shauryatomer1058 Před měsícem

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

  • @priyanshkumar17
    @priyanshkumar17 Před 2 měsíci

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

  • @KILZSNIPPET
    @KILZSNIPPET Před 2 měsíci

    Wrong solution

  • @ChillWithAbhishek
    @ChillWithAbhishek Před 2 měsíci

    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 Před 2 měsíci

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

  • @neev4n
    @neev4n Před 3 měsíci

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

  • @neev4n
    @neev4n Před 3 měsíci

    lowkey the best quickselect explanation ever what

  • @judowithkeishin
    @judowithkeishin Před 3 měsíci

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

  • @jnayehsirine6222
    @jnayehsirine6222 Před 3 měsíci

    great video , it deserves more views

  • @aliramazani2024
    @aliramazani2024 Před 3 měsíci

    I can say this video is the best explanation of the quick select algorithm on CZcams. 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!

  • @apbh
    @apbh Před 4 měsíci

    Isn't the third largest element 10 here?

  • @Nishit_369
    @Nishit_369 Před 5 měsíci

    Awesome explanation. Thanks!!!

  • @mariuszpudzianowski7475
    @mariuszpudzianowski7475 Před 5 měsíci

    great explanation

  • @juancarlosvillanuevaquiros6763

    Super good explanation video. This deserves more views

  • @eriklee1131
    @eriklee1131 Před 6 měsíci

    great video!

  • @akashkadam2741
    @akashkadam2741 Před 6 měsíci

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

  • @akashkadam2741
    @akashkadam2741 Před 6 měsíci

    really well explained

  • @ahmedabdelalem4326
    @ahmedabdelalem4326 Před 6 měsíci

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

  • @bouzie8000
    @bouzie8000 Před 7 měsíci

    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 Před 7 měsíci

    good explanation, thanks

  • @saisardesai5548
    @saisardesai5548 Před 8 měsíci

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

  • @kevinthant2952
    @kevinthant2952 Před 8 měsíci

    Very good explanation, thank you!

  • @beik118
    @beik118 Před 10 měsíci

    really really good video

  • @arandomcoder101
    @arandomcoder101 Před 10 měsíci

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

  • @AbhijeetMishra-bl7yr
    @AbhijeetMishra-bl7yr Před 10 měsíci

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

  • @AbhijeetMishra-bl7yr
    @AbhijeetMishra-bl7yr Před 10 měsíci

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

  • @StephaneArcher
    @StephaneArcher Před 10 měsíci

    Great explanation, thank you

  • @surters
    @surters Před 10 měsíci

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

    • @Fran-kc2gu
      @Fran-kc2gu Před 9 měsíci

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

    • @surters
      @surters Před 9 měsíci

      @@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 Před 7 měsíci

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

    • @JimBob1937
      @JimBob1937 Před 5 měsíci

      @@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 Před 4 měsíci

      @@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 Před 11 měsíci

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

  • @MrJ3
    @MrJ3 Před rokem

    What a great, down to earth explanation.

  • @DK-ox7ze
    @DK-ox7ze Před rokem

    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 Před 2 měsíci

      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 Před rokem

    thanks

  • @Sha-256-rath
    @Sha-256-rath Před rokem

    really appreciate your way of explaining😇😇

  • @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 Před rokem

    thank you so much. that was a great explanation

  • @knowsbetter4113
    @knowsbetter4113 Před rokem

    Love from india

  • @attafriski5901
    @attafriski5901 Před rokem

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

  • @middleagedprogrammer-hl6oz

    Really good explanation!

  • @andrii5054
    @andrii5054 Před rokem

    Great Explanation, thank you

  • @karthiklv29
    @karthiklv29 Před rokem

    amazing explanation

  • @spooki6637
    @spooki6637 Před rokem

    thank you for your explanation it is super clear and concise thank you