Suyashi Singhal
Suyashi Singhal
  • Видео 15
  • Просмотров 14 183
Understanding Call Stack in Recursion | Visualization | Recursion Basics
Recursion is a powerful concept in computer science that can be difficult to understand at first. In this video, I cover the basics of recursion and delve deeper into the call stack and memory allocation.
Using a simple function coded in recursion, I provide visualisations to help understand its working. I also provide a code demonstration, showing how to code a recursive function while keeping track of the call stack and memory allocation.
By the end of this video, you will have a solid understanding of recursion, the call stack, and memory allocation. This video is perfect for beginners who are new to recursion or those who want a refresher on the topic.
→ Topic - Recursion Call Stack (Int...
Просмотров: 499

Видео

Recursion 101: Understanding the basics | Recursion Tree | Visualization & Explanation
Просмотров 168Год назад
Recursion is a fundamental concept in computer science, but it can be difficult to understand at first. In this video I have covered the basics of recursion. In order to ensure maximum learning, I explain the concept of recursion by taking a real life analogy and drawing parallels with it. I further explain a simple function coded in recursion and visualize it's working using a recursion tree a...
Longest Common Subsequence | Part 1 | Dynamic Programming | Interview Question(LeetCode #1143)
Просмотров 4592 года назад
In this video I have covered the method of solving the Longest Common Subsequence Problem using Dynamic Programming. This is the first part of the video on LCS. In the second part I will cover the code for optimizing the space complexity further. Do go through the video and try the question yourself before looking at the coding part. → Topic - Dynamic Programming → Space complexity - O(n*m) → T...
Art Time-lapse #Shorts
Просмотров 1293 года назад
even though this is an educational youtube channel, i aim to post such shorts regularly as i believe art and music are incredibly therapeutic!✨ . . . . ✨Followed this amazing RUclips tutorial by "Art With Flo" to get started with Procreate!!✨ Subscribe to my channel for educational content as well as art therapy : ruclips.net/channel/UCDq3WZuqMw_IiagOtcAS_oQ #shorts #art #youtube #procreate #di...
Counting Bits | O(N) | Dynamic Programming + Bit Manipulation | Interview Question(Leetcode #338)
Просмотров 5623 года назад
In this video I have covered the dynamic programming method to solve the problem of counting set bits in a time optimized manner. I have also explained the bit manipulation variation of the code. Go through the explanation and try the questions yourself before looking at the coding part. → Topic - Dynamic Programming, Bit Manipulation → Space complexity - O(n) → Time complexity - O(n) Problem L...
Iterative Preorder Traversal of Binary Tree | Stack | Interview Question(Leetcode #144)
Просмотров 3213 года назад
In this video I have covered the iterative method to do preorder traversal in a binary tree. Go through the explanation and try the questions yourself before looking at the coding part. → Topic - Binary Tree, Stack → Space complexity - O(n) → Time complexity - O(n) Problem Link : leetcode.com/problems/binary-tree-preorder-traversal/ SUBSECTIONS Intro : (0:00) Question Overview (Reading the ques...
Longest Increasing Subsequence | O(NlogN) | Binary Search | DP | Interview Question(LeetCode #300)
Просмотров 9 тыс.3 года назад
In this video I have covered two methods of solving the Longest Increasing Subsequence Problem - i.e using DP and using Binary Search. Do go through both of them and try the questions yourself before looking at the coding part. → Topic - Dynamic Programming, Binary Search → Space complexity - O(n) → Time complexity - O(nlogn)[Binary Search] , O(n^2)[Dynamic Programming] Problem Link : leetcode....
Add Two Numbers | C++ | Interview Question (Leetcode #2)
Просмотров 2993 года назад
→ Topics - Linked List, Basic Maths → Space complexity - O(max(n1, n2)) → Time complexity - O(max(n1, n2)) n1 - number of nodes in linked list 1 n2 - number of nodes in linked list 2 Problem Link : leetcode.com/problems/add-two-numbers/ SUBSECTIONS Intro : (0:00) Question Overview (Reading the question) : (0:03) In-depth Analysis (Dry running example problem) : (2:51) Code it (Coding Solution) ...
Microsoft Engage Video | Suyashi Singhal
Просмотров 623 года назад
#microsoft #engage #meet-oh-meet #ms #mentorship #video
Two Sum | O(n) | C++| Interview Question (Leetcode #1)
Просмотров 3373 года назад
→ Topic - Hash maps , Arrays → Space complexity - O(n) → Time complexity - O(n) Problem Link : leetcode.com/problems/two-sum/ SUBSECTIONS Intro : (0:00) Question Overview (Reading the question) : (0:22) In-depth Analysis (Dry running example problem) : (2:27) Code it (Coding Solution) : (6:23) Space-Time Complexity ( Isn’t it obvious?) : (9:18) Follow me on social media: Instagram : instagram.c...
Partition List | C++ | Interview Question(Leetcode #86)
Просмотров 4133 года назад
→ Problem name - Partition List → Topic - Linked List → Space complexity - O(1) → Time complexity - O(n) Problem Link : leetcode.com/problems/partition-list/ SUBSECTIONS Intro : (0:00) Question Overview (Reading the question) : (0:14) In-depth Analysis (Dry running example problem) : (1:55) Code it (Coding Solution) : (4:29) Space-Time Complexity ( Isn’t it obvious?) : (8:34) Follow me on socia...
Middle of linked list | C++ | Interview Question(Leetcode #876)
Просмотров 2713 года назад
→ Problem name - Middle of Linked List → Topic - Linked List → Space complexity - O(1) → Time complexity - O(n) Problem Link : leetcode.com/problems/middle-of-the-linked-list/ SUBSECTIONS Intro : (0:00) Question Overview (Reading the question) : (0:06) In-depth Analysis (Dry running example problem) : (2:13) Code it (Coding Solution) : (5:13) Space-Time Complexity ( Isn’t it obvious?) : (7:00) ...
Odd Even Linked List | C++ | Interview Question(Leetcode #328)
Просмотров 3653 года назад
→ Problem name - Odd Even Linked List → Topic - Linked List → Space complexity - O(1) → Time complexity - O(n) Problem Link : leetcode.com/problems/odd-even-linked-list/ SUBSECTIONS Intro : (0:00) Question Overview (Reading the question) : (0:12) In-depth Analysis (Dry running example problem) : (2:21) Code it (Coding Solution) : (6:16) Space-Time Complexity ( Isn’t it obvious?) : (8:55) Follow...
Linked List Cycle | C++ | Interview Question (Leetcode #141)
Просмотров 3463 года назад
→ Problem name - Linked List Cycle → Topic - Linked List → Space complexity - O(n) → Time complexity - O(n) Problem Link : leetcode.com/problems/linked-list-cycle/ SUBSECTIONS Intro : (0:00) Question Overview (Reading the question) : (0:17) In-depth Analysis (Dry running example problem) : (3:32) Code it (Coding Solution) : (6:00) Space-Time Complexity ( Isn’t it obvious?) : (7:59) Follow me on...
Range Sum of BST | C++ | Interview Question (Leetcode #938)
Просмотров 5423 года назад
→ Problem name - Range Sum of BST → Topic - Binary Search Tree , Recursion → Space complexity - O(max depth of tree) → Time complexity - O(n) Problem Link : leetcode.com/problems/range-sum-of-bst/ SUBSECTIONS Intro : (0:00) Question Overview (Reading the question) : (0:16) In-depth Analysis (Dry running example problem) : (1:58) Code it (Coding Solution) : (4:47) Space-Time Complexity ( Isn’t i...

Комментарии

  • @coderatul
    @coderatul 9 месяцев назад

    loved the visualization

  • @sameertripathi1855
    @sameertripathi1855 Год назад

    There is also a solution that takes O(N) time and O(1) space

  • @numbtubeyou
    @numbtubeyou Год назад

    great expalantion, thanks. Would be great to see a way of arriving at this solution from first principles or from hints/thoughts, etc

  • @ernestobenson2948
    @ernestobenson2948 Год назад

    🙄 "PromoSM"

  • @Polly10189
    @Polly10189 Год назад

    Please upload more videos, your way of teaching is very awesome. Thanks

  • @akshaygupta7347
    @akshaygupta7347 2 года назад

    Really nice and clear explanation.

  • @ashishverma1382
    @ashishverma1382 2 года назад

    nice explanation mam !!!

  • @LearnCodeHS
    @LearnCodeHS 2 года назад

    Please don't jump directly to 2D matrix. Explain the intuition first. I hope this helps!

  • @ramprasadreddy8607
    @ramprasadreddy8607 2 года назад

    This code crashed in binSearch function for me for below input data [10, 22, 9, 33, 21, 50, 41, 60, 22, 68, 90] I took code @time 16:40 in video

  • @ajinkya-wasnik
    @ajinkya-wasnik 2 года назад

    Hey Suyashi, great explanation for the problem and the approach to solve that. Although I have one issue with the correctness of the Binary Search solution. It fails for test cases like [10,9,2,5,3,7,101,102,103,104,4] or [10,9,2,5,3,7,101,4]. You'd understand the malfunctioning once you try printing the lis vector. Instead of getting [2,3,7,101] for [10,9,2,5,3,7,101,4] input it'd return [2,3,4,101]. Try to work such examples by yourself and you'd get my point.

  • @emilyhuang2759
    @emilyhuang2759 2 года назад

    I don't get how binary search is an approach to finding a subsequence. Usually binary search is used on a sorted array. How is it possible to find the answer with binary search?

  • @ritwik121
    @ritwik121 2 года назад

    hi can you make a video on regular expression matching and it will be great if u can start with the recursive approach and then move to tabulation one. thanks

  • @motivation_waala
    @motivation_waala 2 года назад

    Hi

  • @CostaKazistov
    @CostaKazistov 2 года назад

    Nice and clear DP walkthrough of LCS algorithm. Many thanks!!

  • @natachijs2566
    @natachijs2566 2 года назад

    Awesome 🙌

  • @aiyazm7278
    @aiyazm7278 2 года назад

    😇✌️

  • @AnshulYadav-os2mw
    @AnshulYadav-os2mw 2 года назад

    Very well explained!! Thanks for making this amazing video👏

  • @CostaKazistov
    @CostaKazistov 2 года назад

    Brilliant!

  • @CostaKazistov
    @CostaKazistov 2 года назад

    Nice one. I found this video after solving same Leetcode question earlier today. Really liked your clear explanation in C++. Looking forward to future Leetcode videos on this channel.

  • @CostaKazistov
    @CostaKazistov 2 года назад

    Excellent walkthrough of NlogN solution for Leetcode 300. It finally makes sense. I watched other videos of NlogN solution for this Leetcode problem and none were as clear as this. It was a nice bonus comparing it with DP solution.

  • @NoName-ip4tt
    @NoName-ip4tt 2 года назад

    Very clear and lucid explanation, thanks. By the way C++ offers std::lower_bound function to conduct binary search for this type of queries. FYI.

    • @suyashisinghal7175
      @suyashisinghal7175 2 года назад

      Thanks a lot! Yeah, could have used inbuilt binary search too!

    • @NoName-ip4tt
      @NoName-ip4tt 2 года назад

      @@suyashisinghal7175 Please keep producing this type of content.

    • @suyashisinghal7175
      @suyashisinghal7175 2 года назад

      @@NoName-ip4tt Sure! Working on that!

  • @ritwik121
    @ritwik121 2 года назад

    this is the only video .... that made the nlogn approach clear to me .... thanks a lott

  • @prakashkumar-zk5ce
    @prakashkumar-zk5ce 2 года назад

    Great explained. I saw lots of video of this problem but your videos make understand finally 😍

  • @condemned8916
    @condemned8916 2 года назад

    Thanks a lot for the clear explanation. Once the logic is clear the code becomes simple as well.

  • @shreyasb7857
    @shreyasb7857 2 года назад

    Crystal clear explanation. Well done.

  • @backflipinspace
    @backflipinspace 2 года назад

    this nlogn method is WRONG! it does not work for my arr = [5,2,8,6,3,6,9,5]. just before i check the last element of "arr", i.e. 5, my "lis" so far looked like this [2,3,6,9]. but then we take the last element 5, and we find the smallest element which is greater than equal to 5, which is 6 in this case and it replaces it; making the final seq as [2,3,5,9], which is incorrect. its not a valid sequence from the original array. also we don't need to do binary search to find out if all elements in "lis" are smaller than the current element we are trying to add in. since lis is sorted we can just check the last element directly and append if it meets the condition.

    • @FranciscoCostaRamos
      @FranciscoCostaRamos 2 года назад

      Can you share the fix? or the idea to it?

    • @CostaKazistov
      @CostaKazistov 2 года назад

      Hmm, strange - it worked for me (exact same code as as in this video). LeetCode accepted it. Runtime: 22 ms, faster than 64.88% of C++ online submissions for Longest Increasing Subsequence. Memory Usage: 10.5 MB, less than 63.26% of C++ online submissions for Longest Increasing Subsequence. class Solution { public: int binSearch(vector<int>& LIS, int target) { int low = 0, high = LIS.size() - 1, ans = INT_MAX; while (low <= high) { int mid = low + (high - low) / 2; if (LIS[mid] < target) low = mid + 1; else { ans = min(ans, mid); high = mid - 1; } } return ans == INT_MAX ? -1 : ans; } int lengthOfLIS(vector<int>& nums) { vector<int> LIS; LIS.push_back(nums.front()); for (int i = 1; i < nums.size(); ++i) { int pos = binSearch(LIS, nums[i]); if (pos == -1) LIS.push_back(nums[i]); else LIS[pos] = nums[i]; } return LIS.size(); } };

    • @backflipinspace
      @backflipinspace 2 года назад

      @@FranciscoCostaRamos sorry i realised the problem after sometime but didn't update here. my claim here is correct. the algorithm in the video does not give you the correct subsequence...bcoz it's only meant to give you the correct subsequence's "length". the length of the longest subseq given by the video's algo will always be correct since it's only trying to find one best solution. ps: if you want the correct sequence as well then try "patiance sort" algorithm. there's a yt channel called StableSort who explained this question using patiance sort very well.

    • @backflipinspace
      @backflipinspace 2 года назад

      @@CostaKazistov yes this algo will get accepted on leetcode bcoz even though it does not give the correct subsequence, it will give the correct answer's length...and that's all is asked on leetcode. if the expected output were an array, you will get wrong result using this method. try patiance sort instead. it also works in nlogn and gives the correct sequence as well.

    • @suyashisinghal7175
      @suyashisinghal7175 2 года назад

      The question asks for a program that finds the length of the longest increasing subsequence. The array that we obtain is not actually the lis, however it's final length does give the length of the lis which is our aim in this question. The binary search algorithm basically maintains an array upto a particular index such that the length of the array is equal to the length of lis. Every time we get a new element, if the element is greater than the last element in the array, we simply add the element in our array(thus increasing length of lis by 1). On the other hand, if the new element is smaller than the last element in the array, we cannot increase the length of the array( and hence the LIS), but we can find the element just greater than it and replace that with the new element. This gives us an array that has the same length as the lis upto that index but containing a smaller value than before. Updating values in this manner helps us to accommodate the future index values and hence obtain an array with a length equal to the length of the lis.

  • @baokemom9640
    @baokemom9640 2 года назад

    The O(NlogN) algorithm is not actually maintaining a LIS array. The i-th position of the array is the smallest possible "ending" value of an increasing subsequence (IS) of length i+1. Considering nums = [0, 2, 3, 1], it'll produce [0, 1, 3] which is not a legal subsequence. [0, 1, 3] actually corresponds to IS [0] (of length 1), [0, 1] (of length 2) and [0, 2, 3] (of length 3)

  • @otmtrader3089
    @otmtrader3089 2 года назад

    Finally!! Found someone who explained nlogn solution in an understandable manner. Thanks a lot.

  • @austinclark3439
    @austinclark3439 3 года назад

    Great video!

  • @theanshu_28
    @theanshu_28 3 года назад

    easy to understand :) thanks for sharing :-))

  • @cherylshire1225
    @cherylshire1225 3 года назад

    Nice! Make a few more of these, with slightly differences, so they will be longer! TIming is good, just a bit too short! I also have an RUclips channel, go check it out?

    • @suyashisinghal7175
      @suyashisinghal7175 3 года назад

      Thank u so much for the suggestions! And yes I will definitely check out ur channel too. ☺🌸

  • @alien_X1
    @alien_X1 3 года назад

    Shorts lao

  • @pulkitgupta8780
    @pulkitgupta8780 3 года назад

    Very beautifully explained!!

  • @Mrcazz-op6qv
    @Mrcazz-op6qv 3 года назад

    🔥

  • @itssky09
    @itssky09 3 года назад

    🔥🔥

  • @MrLokhande
    @MrLokhande 3 года назад

    👍

  • @MrLokhande
    @MrLokhande 3 года назад

    Voice is awesome

  • @MrLokhande
    @MrLokhande 3 года назад

    💯🤟🏻

  • @renukarajpuria2574
    @renukarajpuria2574 3 года назад

    Great 🤩

  • @Almatten
    @Almatten 3 года назад

    That was very good, keep it up 👍

  • @LetsCodeWithUs
    @LetsCodeWithUs 3 года назад

    Nicely explained

  • @amitsahu6171
    @amitsahu6171 3 года назад

    that was greatly explained :-)

  • @pulkitgupta8780
    @pulkitgupta8780 3 года назад

    You made this so easy to understand !!

  • @ayushmahant7134
    @ayushmahant7134 3 года назад

    Nice explanation of nlogn solution

  • @roy.galaxy
    @roy.galaxy 3 года назад

    Nice

  • @akshaygupta6745
    @akshaygupta6745 3 года назад

    Check this out 🙃 #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } int dp[n+1]; //length from 0-n dp[0]=INT_MIN; for(int i=1;i<=n;i++){ dp[i]=INT_MAX; } for(int i=1;i<=n;i++){ int idx=upper_bound(dp,dp+n+1,a[i]) -dp; if(dp[idx-1]<a[i] and a[i]<dp[idx]){ dp[idx]=a[i]; } } int ans=0; for(int i=1;i<=n;i++){ if(dp[i]!=INT_MAX){ ans=i; } } cout<<ans; return 0; }

  • @AbhishekMadhu_online
    @AbhishekMadhu_online 3 года назад

    Hi, great content. Thanks a lot!

  • @meettrivedi991
    @meettrivedi991 3 года назад

    Great🤟🏻

  • @zaarzet
    @zaarzet 3 года назад

    🔥🔥🔥

  • @syedfahim9759
    @syedfahim9759 3 года назад

    #classmate 😀