Aryan Mittal
Aryan Mittal
  • 902
  • 8 322 793
1382, 108 Balance a Binary Search Tree | Day-Stout-Warren (DSW) Algorithm | In-Place Balancing
In this video, I'll talk about how to solve Leetcode 1382. Balance a Binary Search Tree | Day-Stout-Warren Algorithm | In-Place Balancing | Inorder | Greedy | 108. Convert Sorted Array to Binary Search Tree
Tree Traversals + Morris Traversal - ua-cam.com/video/EuhrPsgc0L8/v-deo.html
Let's Connect:
📱Discord (Join Community) : discord.gg/vwUAz2pEHZ
📝Linkedin: www.linkedin.com/in/aryan-mittal-0077
📸 Instagram: codeWithAryanBhai
💻 Twitter - aryan_mittal007
🤖 Github: github.com/aryan-0077
About Me:
I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
✨ Timelines✨
0:00 - Bakwas
0:21 - Problem Explanation
3:24 - Leetcode 108. Convert Sorted Array to Binary Search Tree
7:18 - Inorder Traversal & Code Explanation
10:59 - DSW Algorithm
15:12 - Right & Left Rotation
20:04 - Convert BST to Backbone/Vine
25:18 - Convert BackBone to Complete Binary Tree
34:28 - Code Explanation Combined
✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms
Переглядів: 1 009

Відео

1038. Binary Search Tree to Greater Sum Tree | Recursive | Iterative | Morris Traversal
Переглядів 2,4 тис.16 годин тому
In this video, I'll talk about how to solve Leetcode 1038. Binary Search Tree to Greater Sum Tree | Recursive | Iterative | Morris Traversal - Super Important Tree Traversal Morris Traversal - ua-cam.com/video/EuhrPsgc0L8/v-deo.html Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: codeWithAryanBhai 💻 Twi...
995, 3191, 3192 Minimum Number of K Consecutive Bit Flips | Bit Manipulation | Sliding Wind | Greedy
Переглядів 7 тис.19 годин тому
In this video, I'll talk about how to solve Leetcode 995. Minimum Number of K Consecutive Bit Flips | Bit Manipulation | Prefix Technique | 3191. Minimum Operations to Make Binary Array Elements Equal to One I | 3192. Minimum Operations to Make Binary Array Elements Equal to One II BIT MANIPULATION Crash Course 📈 | All Tricks & Pattern with Intuition for DSA & CP - ua-cam.com/video/DDIVTbatu1Y/...
3196. Maximize Total Cost of Alternating Subarrays | DP | 0/1 Knapsack
Переглядів 2,5 тис.21 годину тому
In this video, I'll talk about how to solve Leetcode 3196. Maximize Total Cost of Alternating Subarrays | DP | 0/1 Knapsack Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: codeWithAryanBhai 💻 Twitter - aryan_mittal007 Github: github.com/aryan-0077 About Me: I am Aryan Mittal - A Software En...
1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit | 3 Approaches
Переглядів 4,4 тис.21 годину тому
In this video, I'll talk about how to solve Leetcode 1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit | 2 Pointer | Multiset | Priority Queue | Deque | 3 Approaches 2 Pointer Crash Course - ua-cam.com/video/ZZ5bOSRxAqM/v-deo.html Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: instagra...
3193. Count the Number of Inversions | DP Time Complexity | Two Pointer | DP Space Optimized
Переглядів 2,4 тис.21 годину тому
In this video, I'll talk about how to solve 3193. Count the Number of Inversions | DP Time Complexity | Two Pointer | DP Space Optimized Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: codeWithAryanBhai 💻 Twitter - aryan_mittal007 Github: github.com/aryan-0077 About Me: I am Aryan Mittal - ...
1248. Count Number of Nice Subarrays | Prefix Sums | Sliding Window | Same as Leetcode 930
Переглядів 5 тис.День тому
In this video, I'll talk about how to solve Leetcode 1248. Count Number of Nice Subarrays | Prefix Sums | Sliding Window | Same as Leetcode 930 2 Pointer Crash Course - ua-cam.com/video/ZZ5bOSRxAqM/v-deo.html Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: codeWithAryanBhai 💻 Twitter - aryan...
1052. Grumpy Bookstore Owner | Sliding Window | Walmart Labs | EPAM Systems
Переглядів 4,7 тис.День тому
In this video, I'll talk about how to solve Leetcode 1052. Grumpy Bookstore Owner | Sliding Window | Walmart Labs | EPAM Systems Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: codeWithAryanBhai 💻 Twitter - aryan_mittal007 Github: github.com/aryan-0077 About Me: I am Aryan Mittal - A Softwa...
1552. Magnetic Force Between Two Balls | Binary Search on Answer | Greedy
Переглядів 6 тис.День тому
In this video, I'll talk about how to solve Leetcode 1552. Magnetic Force Between Two Balls | Binary Search on Answer | Greedy Binary Search on Answer - ua-cam.com/video/nBchKqaVwd8/v-deo.html Binary Search Template - ua-cam.com/video/UZx_DI4z_l8/v-deo.html Binary Search Practice Problems - ua-cam.com/play/PLEL7R4Pm6EmA-wPsAXrlDVYpIcrJGFwX5.html Let's Connect: 📱Discord (Join Community) : discor...
1482. Minimum Number of Days to Make m Bouquets | Binary Search | Problem Statement 🤡 Problem 🗿
Переглядів 3,2 тис.День тому
In this video, I'll talk about how to solve Leetcode 1482. Minimum Number of Days to Make m Bouquets | Binary Search | Problem Statement 🤡 Problem 🗿 Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: codeWithAryanBhai 💻 Twitter - aryan_mittal007 Github: github.com/aryan-0077 About Me: I am Ary...
826. Most Profit Assigning Work | 5 Approaches | Greedy | Binary S | Priority Queue | 2 Pointer | DP
Переглядів 4,8 тис.День тому
In this video, I'll talk about how to solve Leetcode 826. Most Profit Assigning Work | 5 Approaches | Binary Search | Priority Queue | 2 Pointer | DP | Greedy Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: codeWithAryanBhai 💻 Twitter - aryan_mittal007 Github: github.com/aryan-0077 About Me...
633. Sum of Square Numbers | Math | 2 Pointer | Binary Search | Two Sum
Переглядів 3,5 тис.День тому
In this video, I'll talk about how to solve Leetcode 633. Sum of Square Numbers | Math | 2 Pointer | Binary Search | Two Sum 2Sum - ua-cam.com/video/yX-digEslp4/v-deo.html Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: codeWithAryanBhai 💻 Twitter - aryan_mittal007 Github: github.com/aryan-...
3185. & 3184 Count Pairs That Form a Complete Day II | Same as Two Sum | Modulo Operation
Переглядів 2,4 тис.День тому
In this video, I'll talk about how to solve Leetcode 3185. Count Pairs That Form a Complete Day II | 3184. Count Pairs That Form a Complete Day I | Same as Two Sum 2Sum - ua-cam.com/video/yX-digEslp4/v-deo.html Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: codeWithAryanBhai 💻 Twitter - ary...
3186. Maximum Total Damage With Spell Casting | DP + Binary Search | Same as LIS
Переглядів 3,6 тис.День тому
In this video, I'll talk about how to solve Leetcode 3186. Maximum Total Damage With Spell Casting | DP | Same as LIS Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: codeWithAryanBhai 💻 Twitter - aryan_mittal007 Github: github.com/aryan-0077 About Me: I am Aryan Mittal - A Software Engineer...
3187. Peaks in Array | Segment Tree | Range Sum | 2 Line Change in Template | Fenwick Tree
Переглядів 1,7 тис.День тому
In this video, I'll talk about how to solve Leetcode 3187. Peaks in Array | Segment Tree | Range Sum | 2 Line Change in Template Segment Tree Crash Course - ua-cam.com/video/NofRIGE7oWU/v-deo.html Fenwick Tree Crash Course - ua-cam.com/video/Qe8qRhz3lzQ/v-deo.html Let's Connect: 📱Discord (Join Community) : discord.gg/vwUAz2pEHZ 📝Linkedin: www.linkedin.com/in/aryan-mittal-0077 📸 Instagram: insta...
330. Patching Array | Greedy | Array | Math | Why not Bitset Trick
Переглядів 6 тис.День тому
330. Patching Array | Greedy | Array | Math | Why not Bitset Trick
502. IPO | Greedy | Priority Queue | Sorting | Zeta | Salesforce | Amazon
Переглядів 3,9 тис.День тому
502. IPO | Greedy | Priority Queue | Sorting | Zeta | Salesforce | Amazon
945. Minimum Increment to Make Array Unique | Greedy | Counting Sort
Переглядів 3,8 тис.День тому
945. Minimum Increment to Make Array Unique | Greedy | Counting Sort
2037. Minimum Number of Moves to Seat Everyone | Greedy | Counting Sort
Переглядів 2,5 тис.День тому
2037. Minimum Number of Moves to Seat Everyone | Greedy | Counting Sort
75. Sort Colors | 2 Pointers | Super Important Interview Question | 100Days 100K Placements
Переглядів 1,6 тис.14 днів тому
75. Sort Colors | 2 Pointers | Super Important Interview Question | 100Days 100K Placements
1122. Relative Sort Array | Counting Sort Deep | Map | 2 Approaches | Amazon | Apple | De shaw
Переглядів 2,2 тис.14 днів тому
1122. Relative Sort Array | Counting Sort Deep | Map | 2 Approaches | Amazon | Apple | De shaw
1051. Height Checker | All form of Sort Complexity | Counting Sort
Переглядів 2 тис.14 днів тому
1051. Height Checker | All form of Sort Complexity | Counting Sort
3178. Find the Child Who Has the Ball After K Seconds | Math | Cyclic Math Pattern
Переглядів 91414 днів тому
3178. Find the Child Who Has the Ball After K Seconds | Math | Cyclic Math Pattern
3179. Find the N-th Value After K Seconds | Pascal's Triangle | DP | Bottom Up Optimised DP
Переглядів 99914 днів тому
3179. Find the N-th Value After K Seconds | Pascal's Triangle | DP | Bottom Up Optimised DP
3181 & 3180 | BitSet Crash Course | DP | 3181. Maximum Total Reward Using Operations II & I
Переглядів 6 тис.14 днів тому
3181 & 3180 | BitSet Crash Course | DP | 3181. Maximum Total Reward Using Operations II & I
974. Subarray Sums Divisible by K | PrefSum | Not an Easy Problem
Переглядів 4 тис.14 днів тому
974. Subarray Sums Divisible by K | PrefSum | Not an Easy Problem
3174. Clear Digits | Simulation | Arrays | 2 Pointers
Переглядів 1,1 тис.14 днів тому
3174. Clear Digits | Simulation | Arrays | 2 Pointers
3175. Find The First Player to win K Games in a Row | 2 Approaches | One Pass | Simulation
Переглядів 1,5 тис.14 днів тому
3175. Find The First Player to win K Games in a Row | 2 Approaches | One Pass | Simulation
3177 & 3176 Find the Maximum Length of a Good Subsequence II & Subsequence I I | DP | LIS
Переглядів 4,8 тис.14 днів тому
3177 & 3176 Find the Maximum Length of a Good Subsequence II & Subsequence I I | DP | LIS
523. Continuous Subarray Sum | Prefix Sums | Hash Map | Meta
Переглядів 5 тис.14 днів тому
523. Continuous Subarray Sum | Prefix Sums | Hash Map | Meta

КОМЕНТАРІ

  • @theUnkown617
    @theUnkown617 14 годин тому

    You said there is no recursive extra space used but in the editorial they mentioned that there will be O(N) extra space for recursive stack could you clarify that ?

  • @akshaysmart6257
    @akshaysmart6257 15 годин тому

    new fear unlocked learning DSA after seeing this DSW algorithm as a beginner🥲🥲

  • @vaxxnsh
    @vaxxnsh 15 годин тому

    Maksad pura ho gya 👍

  • @learpcss9569
    @learpcss9569 16 годин тому

    dp without any additional flags/states: dp[i + 1] = max(dp[i + 1], dp[i] + a[i]); dp[i + 2] = max(dp[i + 2], dp[i] + a[i] - a[i + 1]);

  • @kunalkumarshukla137
    @kunalkumarshukla137 17 годин тому

    bhai ive watched at;east 10 15 videos on lps kmp but could'nt get the intuition for some time i could mug up..but forget after some time...this time i got the proper intuition thanks so much

  • @chakri6262
    @chakri6262 17 годин тому

    💀😂

  • @dhaanaanjaay
    @dhaanaanjaay 17 годин тому

    You and neetcode both rock🤟🤟🤟

  • @6mahine_mein_google
    @6mahine_mein_google 18 годин тому

    @18:47 in the example u took in the code it should be parent->left = temp , and this code works in the final code beacuse we are doing left rotations only in the right subtrees of the skewed vinetree .

  • @codebreaker6578
    @codebreaker6578 18 годин тому

    please explain when i am taking vector<int> arr for storing the values in sorted order , and then making tree from the arr is taking 762ms while vector<TreeNode*> arr is talking 62ms . why the time is differed this much ?

    • @btechstudent1620
      @btechstudent1620 18 годин тому

      just dont care abt the time that leetcode , even u run the same code at a very different time then always u will see huge variation in the time

    • @codebreaker6578
      @codebreaker6578 16 годин тому

      @@btechstudent1620 i know that thing but that's a huge difference and also he mentioned to use TreeNode

  • @Munchen888
    @Munchen888 18 годин тому

    Some hints 😊: 1. gather into list 2. use partition to divide on equal parts

  • @PulkitAgg13
    @PulkitAgg13 18 годин тому

    Have they asked AVL Tree by using confusing language?

  • @user-ip9kr9nz9t
    @user-ip9kr9nz9t 19 годин тому

    The level motivation this guy has is astounding

  • @satwiktatikonda764
    @satwiktatikonda764 20 годин тому

    how are you this much consistent bro😱😱

  • @rhydhamsingla9597
    @rhydhamsingla9597 21 годину тому

    very nice explanation. I appreciate your efforts brother. I also have an ques, in the video you said that we "assume" that this is gonna give us a perfect tree, so i wanna know that does this algorithm have a fail or that was your way of teaching?

  • @shahzodshafizod
    @shahzodshafizod 22 години тому

    Simpil bro, simpil)

  • @Three_Swords_Zoro
    @Three_Swords_Zoro 22 години тому

    I guess the 2nd approach fails for this testcases like "***(((" as the approach will return true but its not.

  • @lokesh8660
    @lokesh8660 23 години тому

    waiting for today's dc in place modification approach 🥲

  • @smarthu4617
    @smarthu4617 День тому

    don't try to over act plz explain the solutions calmly.

  • @gadgetsandhacks7161
    @gadgetsandhacks7161 День тому

    how are you considering the fact that if we are going on to a node B via a node(lets say A) such that to reach that A the disapperaing time was okay for A but how can you say that if we go to B the node A still present there. In short how are you sure that to go to some far nodes how the closer noodes are gonna be still not disappeared.

  • @jyotiprakashnath1118
    @jyotiprakashnath1118 День тому

    easy ko tough bana dete ho bhai

  • @sachinvarma9949
    @sachinvarma9949 День тому

    awesome explanation

  • @satwiktatikonda764
    @satwiktatikonda764 День тому

    floyd warshall

  • @cenacr007
    @cenacr007 День тому

  • @insaneclutchesyt948
    @insaneclutchesyt948 День тому

    my dumbass thought vertical order traversal to get the sum of all the right nodes

  • @AnkitYadav-up4
    @AnkitYadav-up4 День тому

    first time hindi me suna apko

  • @abhishektripathi3904
    @abhishektripathi3904 День тому

    Great explanation!

  • @asmitshukla4649
    @asmitshukla4649 День тому

    today i learned how to use inputs for our advantage, and also learned the beautiful technique of flipping of bits without actually flipping them, but by just knowing the fact that "a bit flipped even times will remain same and flipping it odd times will change it". thanks aryan bhaiya

  • @ayushmaanbn6228
    @ayushmaanbn6228 День тому

    I am getting Memory Limit Exceeded, #define ll long long int class Solution { public: vector<vector<vector<ll>>> dp; ll solve( vector<int> nums, int i, int start, int sign ) { if( i == nums.size() ) return 0; if( dp[i][start][sign] != -1e15 ) return dp[i][start][sign]; ll answer = -1e15; if( start == 0 ) answer = max( answer, nums[i] + solve( nums, i+1, 1, sign^1 ) ); else { if( sign == 0 ) answer = max( answer, nums[i] + solve( nums, i+1, 1, sign^1 ) ); else answer = max( answer, -nums[i] + solve( nums, i+1, 1, sign^1 ) ); answer = max( answer, solve( nums, i, 0, 0 ) ); } return dp[i][start][sign] = answer; } ll maximumTotalCost(vector<int>& nums) { dp = vector<vector<vector<ll>>>(nums.size()+1, vector<vector<ll>>(2, vector<ll>(2, -1e15))); return solve(nums, 0, 0, 0); } }; Can anyone help me please?

  • @youtubeuserlovesyoutube2207
    @youtubeuserlovesyoutube2207 День тому

    thanks aryan GOAT

  • @AP-xh6dx
    @AP-xh6dx День тому

    nice solution and great explaination Just want to ask if partition DP will work on it or not?

  • @GYANKIBAAT-ze7nd
    @GYANKIBAAT-ze7nd День тому

    Bro 4th question kahan hai?

  • @mohd.vaseem7410
    @mohd.vaseem7410 День тому

    this code is failing on the last test case on leetcode

  • @hydrocy.9165
    @hydrocy.9165 День тому

    how does code figure out sub nodes are called leftNode and rightNode?

  • @monicapatidar5806
    @monicapatidar5806 День тому

    Can you make a playlist for 150 leetcode interview questions

  • @codebreaker6578
    @codebreaker6578 День тому

    can you please explain how recursive is using O(n) space , in itertative it's because of stack

  • @anandtiwari8606
    @anandtiwari8606 День тому

    remember cheaters you have to sit in an interview. No telegram or youtube is gonna help you there all you guys who cheat are doing nothing but demotivating average programmer like me who works hard and don't have enough money to buy solutions like you. like other humans i am also not too honest but cheating on a regular basis is never gonna help you.

  • @codebreaker6578
    @codebreaker6578 День тому

    I can't believe myself that i done this problem without watching this video . Because it's my first tree problem ,I just saw GFG how to traverse tree and came up with solution which passed all testcase in single run with time complexity O(N) class Solution { public: int sum=0; void update(TreeNode* node){ if(node==nullptr){ return; } update(node->right); sum+=node->val; node->val=sum; update(node->left); } TreeNode* bstToGst(TreeNode* root) { update(root); return root; } };

  • @codebreaker6578
    @codebreaker6578 День тому

    I didn't do any tree question till now should i do this ?

  • @lavanyam3224
    @lavanyam3224 2 дні тому

    awesome video bro.. could you please upload the other parts as well😊

  • @leechaolan6227
    @leechaolan6227 2 дні тому

    Bhai 34th test case ne pahd diya 🤣🤣

  • @sriramphysics5853
    @sriramphysics5853 2 дні тому

    very very good

  • @deathigniter2155
    @deathigniter2155 2 дні тому

    Please someone tell me whats wrong in my code; int n = arr.size() , m = brr.size() , gp = 0; map < ll ,ll > factors; for(int i = 0; i < m; i++) factors[brr[i]]++; for(int i = 0; i < n; i++){ if(arr[i] % k != 0) continue; int x = arr[i] / k; for(int j = 1; j * j <= x; j++){ if(factors.find(j) != factors.end()) gp += factors[j]; if(j != (x / j) && factors.find(x / j) != factors.end()) gp += factors[x / j]; } } return gp;

    • @deathigniter2155
      @deathigniter2155 2 дні тому

      here is the accepted / corrected code. ll n = arr.size() , m = brr.size() , gp = 0; map < ll ,ll > factors; for(int i = 0; i < m; i++) factors[brr[i]]++; for(int i = 0; i < n; i++){ if(arr[i] % k != 0) continue; int x = arr[i] / k; for(int j = 1; j * j <= x; j++){ if(x % j != 0) continue; if(factors.find(j) != factors.end()) gp += factors[j]; if(j != (x / j) && factors.find(x / j) != factors.end()) gp += factors[x / j]; } } return gp; // arr[i] % (arr[j] * k) == 0; // arr[i] / k = x; // then find factors of x in brr;

  • @mohammedansil2302
    @mohammedansil2302 2 дні тому

    great content......now i get why this guy is a gold medalist in NIT

  • @techyguy7776
    @techyguy7776 2 дні тому

    Great explanation!!

  • @mohit7717
    @mohit7717 2 дні тому

    1st two was coming in this Biweekly Contest...

  • @ashishmohapatra8588
    @ashishmohapatra8588 2 дні тому

    Contest ke questions Bhi saath mein ho gaye

  • @TarunParmar-o9i
    @TarunParmar-o9i 2 дні тому

    a doubt: changing the input array (making element = 2) will still count as O(n) space, how/why?

  • @Zomb-zj4ip
    @Zomb-zj4ip 2 дні тому

    absolutely loved your explanation and the consistent uploads. its baffling how you don't have more audience, wishing you all the very best! and thanks alot!

  • @anushkachouhan5996
    @anushkachouhan5996 2 дні тому

    Thank you bro You are genius.

  • @devt4072
    @devt4072 2 дні тому

    Can you try to explain your dry runs in a more concise manner? I feel like you are trying to spoon-feed the logic which makes the explanation unnecessarily difficult to understand.