C0de Sutra
C0de Sutra
  • 115
  • 112 970
Leetcode 3068 Find the Maximum Sum of Node Values
In this vedio I have discussed the solution to leetcode 3068. Find the Maximum Sum of Node Values
I have used greedy Algorithm to solve this problem.
Problem Link: leetcode.com/problems/find-the-maximum-sum-of-node-values/
Solution Link: leetcode.com/problems/find-the-maximum-sum-of-node-values/discuss/5176842/Beats-100-Video-Solution-or-Java-C%2B%2B-Python
Fresher's Community Link: chat.whatsapp.com/CsvgJRFNZTQAIcujub1gDe
Experienced Community Link: chat.whatsapp.com/IeeHQGlUPK25OFm7mIdv5G
zhlédnutí: 463

Video

LeetCode 979 Distribute Coins in Binary Tree
zhlédnutí 476Před 2 měsíci
Solution to leetcode problem 979.Distribute Coins in Binary Tree I have used post Order traversal to solve this leetcode problem. Telegram Links: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/distribute-coins-in-binary-tree/ Solution Link: leetcode.com/problems/distribute-coins-in-binary-tree/discuss/5172664/Beats-100-Video-Solution-with-Similar-Problems-or-J...
Leetcode 1325. Delete Leaves With a Given Value
zhlédnutí 62Před 2 měsíci
Leetcode 1325. Delete Leaves With a Given Value Given a binary tree root and an integer target, delete all the leaf nodes with value target. Post Order Traversal is used in the solution
Leetcode 1531 String Compression II
zhlédnutí 1,3KPřed 7 měsíci
Solution to leetcode problem 1531. String Compression II I have used Dynamic Programming DP to solve this problem. Telegram Links: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/string-compression-ii/ Solution Link: leetcode.com/problems/string-compression-ii/discuss/4468981/Video-Solution-DP-or-Java-C++-Python
Leetcode 2050 Parallel Courses III
zhlédnutí 767Před 9 měsíci
Solution to leetcode problem 2050. Parallel Courses III I have used Topological Sort to solve this problem. Telegram Links: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: //leetcode.com/problems/parallel-courses-iii/ Solution Link: leetcode.com/problems/parallel-courses-iii/discuss/4180629/Video-Solution-or-Java-C++-Python
Leetcode 1269 Number of Ways to Stay in the Same Place After Some Steps
zhlédnutí 652Před 9 měsíci
Solution to leetcode problem 1269. Number of Ways to Stay in the Same Place After Some Steps I have used Dynamic Programming (DP) to solve this problem. Telegram Links: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/ Solution Link:
Leetcode 2742 Painting the Walls
zhlédnutí 1,3KPřed 9 měsíci
Solution to leetcode problem 2742. Painting the Walls I have used Dynamic Programming (DP) to solve this problem. Telegram Links: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/painting-the-walls/ Solution Link: leetcode.com/problems/painting-the-walls/discuss/4166315/Video-Solution-or-Dynamic-Programming
LeetCode 2251 Number of Flowers in Full Bloom
zhlédnutí 1,1KPřed 9 měsíci
Solution to leetcode problem 2251. Number of Flowers in Full Bloom I have used sorting and Binary Search to solve this problem. Telegram Links: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/number-of-flowers-in-full-bloom/ Solution Link: leetcode.com/problems/number-of-flowers-in-full-bloom/discuss/4155615/Video-Solution-or-Sorting-and-Binary-Search
LeetCode 2009 Minimum Number of Operations to Make Array Continuous
zhlédnutí 1,4KPřed 9 měsíci
Solution to leetcode problem 2009. Minimum Number of Operations to Make Array Continuous. I have used sorting and Sliding window Technique to solve this problem. Telegram Links: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/minimum-number-of-operations-to-make-array-continuous/ Solution Link: leetcode.com/problems/minimum-number-of-operations-to-make-array-co...
Leetcode 1203 Sort Items by Groups Respecting Dependencies
zhlédnutí 3,4KPřed 11 měsíci
Telegram Link: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/sort-items-by-groups-respecting-dependencies/description/ Solution Link: leetcode.com/problems/sort-items-by-groups-respecting-dependencies/solutions/3934487/detailed-video-solution-java-c-python/ Sort Items by Groups Respecting Dependencies is leetcode 1489 and we are using Topological Sort to solv...
Leetcode 1489 Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree
zhlédnutí 1KPřed 11 měsíci
Telegram Link: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/ Solution Link: leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/discuss/3929349/Detailed-Video-+-Solution-or-Java-C++-Python Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree is lee...
Leetcode 542 01 Matrix
zhlédnutí 1,4KPřed 11 měsíci
Telegram Link: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/01-matrix/ Solution Link: leetcode.com/problems/01-matrix/discuss/3920311/Greedy-Beats-100-or-Java-C++-Python 01 Matrix is leetcode 542 and we are using greedy algorithm to solve this problem. The time and space complexity are O(N*M) and O(1).
Leetcode 2369 Check if There is a Valid Partition For The Array
zhlédnutí 815Před 11 měsíci
Workshop Link:jeevankumar.co.in/ Telegram Link: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/check-if-there-is-a-valid-partition-for-the-array Solution Link: leetcode.com/problems/check-if-there-is-a-valid-partition-for-the-array/discuss/3901362/Easy-Explanation-+-Video-or-Java-C++-Python Check if There is a Valid Partition For The Array is leetcode 2369 and...
Leetcode 63 Unique Paths II
zhlédnutí 924Před 11 měsíci
Workshop Link:jeevankumar.co.in/ Telegram Link: t.me/ FieKB7Ds6j02Y2Y1 t.me/ JU-ZF-oDjX4xYjBl Problem Link: leetcode.com/problems/unique-paths-ii/ Solution Link: leetcode.com/problems/unique-paths-ii/discuss/3897008/Beats-100-+Video-or-Java-C++-Python Unique Paths II is leetcode 63 and we are using dynamic programming (dp) to solve this problem. The time and space complexity are O(n*m) and O(n*m).
Leetcode 518 Coin Change II
zhlédnutí 1,2KPřed 11 měsíci
Leetcode 518 Coin Change II
Leetcode 2616 Minimize the Maximum Difference of Pairs
zhlédnutí 2KPřed 11 měsíci
Leetcode 2616 Minimize the Maximum Difference of Pairs
Leetcode 33 Search in Rotated Sorted Array
zhlédnutí 710Před 11 měsíci
Leetcode 33 Search in Rotated Sorted Array
Leetcode 95 Unique Binary Search Trees II
zhlédnutí 2,8KPřed 11 měsíci
Leetcode 95 Unique Binary Search Trees II
Leetcode 17 Letter Combinations of a Phone Number
zhlédnutí 838Před 11 měsíci
Leetcode 17 Letter Combinations of a Phone Number
LeetCode 46 Permutations Java
zhlédnutí 1,7KPřed 11 měsíci
LeetCode 46 Permutations Java
Leetcode 77 Combinations
zhlédnutí 1,9KPřed 11 měsíci
Leetcode 77 Combinations
Leetcode 712 Minimum ASCII Delete Sum for Two Strings
zhlédnutí 1,4KPřed 11 měsíci
Leetcode 712 Minimum ASCII Delete Sum for Two Strings
Leetcode 486 Predict the Winner
zhlédnutí 5KPřed rokem
Leetcode 486 Predict the Winner
Leetcode 2141 Maximum Running Time of N Computers
zhlédnutí 1,6KPřed rokem
Leetcode 2141 Maximum Running Time of N Computers
LeetCode 1870 Minimum Speed to Arrive on Time
zhlédnutí 1,5KPřed rokem
LeetCode 1870 Minimum Speed to Arrive on Time
Leetcode 852 Peak Index in a Mountain Array
zhlédnutí 848Před rokem
Leetcode 852 Peak Index in a Mountain Array
Leetcode 50. Pow(x, n)
zhlédnutí 1,3KPřed rokem
Leetcode 50. Pow(x, n)
LeetCode 688 Knight Probability in Chessboard
zhlédnutí 846Před rokem
LeetCode 688 Knight Probability in Chessboard
LeetCode 673 Number of Longest Increasing Subsequence
zhlédnutí 1,3KPřed rokem
LeetCode 673 Number of Longest Increasing Subsequence
LeetCode 435 Non-overlapping Intervals
zhlédnutí 1,1KPřed rokem
LeetCode 435 Non-overlapping Intervals

Komentáře

  • @shreyarawatvlogs6920

    4.22 where did 7 came from. i didnt understood

  • @subee128
    @subee128 Před 11 dny

    Thanks

    • @c0de_sutra
      @c0de_sutra Před 9 dny

      Welcome! I am glad you liked it.

  • @subee128
    @subee128 Před 12 dny

    Thanks

  • @eyob_worku
    @eyob_worku Před 14 dny

    you are the best

  • @shriramnirmal5535
    @shriramnirmal5535 Před 17 dny

    why are we initialising 0 with count 1 , I couldn't understand that point

    • @shriramnirmal5535
      @shriramnirmal5535 Před 14 dny

      okay got it this 0 is for say like if the sub array is a total array then we should have a value in hash map zero

  • @subee128
    @subee128 Před 19 dny

    thanks

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

    You explained it very nicely. Looking forward to more videos

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

    but what if the [0,0] is not 0?

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

    how to think of this logic sir ?

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

    Keep it going ! :D

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

    you explained the steps but you didn't explain how and why it works

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

    Can you please share the time and space complexities as well

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

    what's the app you using to note?

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

    Fresher's Community Link: chat.whatsapp.com/CsvgJRFNZTQAIcujub1gDe Experienced Community Link: chat.whatsapp.com/IeeHQGlUPK25OFm7mIdv5G

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

    Keep it up man !

  • @user-vp3np7qs2l
    @user-vp3np7qs2l Před 2 měsíci

    Hey bro, will you be uploading answer of daily challenges everyday? and good approach!

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

      Yes Sharan I will be uploading solution for the medium and Hard level problems. Thank you!

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

    Telegram Links: t.me/+FieKB7Ds6j02Y2Y1 t.me/+JU-ZF-oDjX4xYjBl

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

    Similar Problems: leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree/ leetcode.com/problems/binary-tree-cameras/

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

    Please improve your pronunciation. I can’t listen you.

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

    why didnt you finish the seaies.. this is exactly what I was looking for

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

    Good explanation

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

    Like the explaination but solution is far from ideal and will timeout if run with higher inputs

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

    Nice explanation

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

    best explaination for the java submission

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

    00:02 Problem requires step-by-step approach 02:20 Finding the shortest path to collect all keys 04:43 Path to obtaining keys to unlock cells. 07:03 Using binary representation to store key configurations efficiently 09:15 Using numbers to represent key configurations simplifies identification 11:37 Algorithm for finding shortest path to get all keys. 13:49 Finding the shortest path to get all keys with specific conditions. 16:03 Traversal and key management in pathfinding algorithm. 18:00 Iterating over elements in the queue and updating steps

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

    code for pair ?

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

    brute force solution is incorrect. It will fail on the test case [1,100,5]. Explanation: One possible case is when player 1 picks 5. Player 2 picks 1. Player 1 picks 100. This situation will arise because you are considering all possible cases and this case will also fall under it. Your solution will return true but expected answer is false

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

    Thank you for your explanation! It's better than on many other channels!

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

    in 10:19 why to take a2 for a7 and for a10 to a3 I did'nt understand this

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

      It's the length of the new String i.e a7 has a length of 2 and a10 has a length of 3

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

    This is my java solution: Logically It makes sense to me but I am having trouble with the testcases, any pointers will help: class Solution { public int getLengthOfOptimalCompression(String s, int k) { int[][] x = new int[s.length() + 1][k + 1]; for(int[] j : x){ Arrays.fill(j, -1); } return find(s, k, 0, x, Character.MIN_VALUE, 0); } int find(String s, int k, int index, int[][] x, char cur, int charcount){ if(k == 0 || index >= s.length()){ return Calculate_len(s, index); } if(x[index][k] != -1){ return x[index][k]; } int count = 0; if(cur != s.charAt(index)){ String num = String.valueOf(charcount); int val = 0; if(num.equals("1")){ val = 1; } else if(num.equals("0")){ val = 0; } else{ val = num.length() + 1; } // System.out.println(num + " " + val); count = Math.min(find(s, k, index + 1, x, s.charAt(index),1) + val, find(s, k - 1, index + 1, x, cur, charcount)); } else{ count = Math.min(find(s, k, index + 1, x, s.charAt(index),charcount + 1), find(s, k - 1, index + 1, x, cur, charcount)); } x[index][k] = count; // System.out.println(x[index][k] + " " + index + " " + k); return x[index][k]; } int Calculate_len(String s, int index){ if(index >= s.length()){ return 0; } String ns = s.substring(index); int i = 0; int fin_count = 0; while(i < ns.length()){ int count = 1; while(i < ns.length() - 1 && ns.charAt(i) == ns.charAt(i + 1)){ count++; i++; } if(count == 1){ fin_count++; } else{ String num = String.valueOf(count); fin_count += (num.length() + 1); } i++; } return fin_count; } }

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

    Check out our community of 400+ people: t.me/+FieKB7Ds6j02Y2Y1

  • @user-ih2ww9nv7d
    @user-ih2ww9nv7d Před 7 měsíci

    class Solution { public: int dp[102][102]; int find(int n){ if(n==1) return 1; if(n>1 and n<10) return 2; if(n>=10 and n<100) return 3; return 4; } int solve(string &s,int k,int idx){ if(k<0) return s.size(); if(idx>=s.size() || (s.size()-idx)<=k) return 0; if(dp[idx][k]!=-1) return dp[idx][k]; int ans=s.size(); ans=solve(s,k-1,idx+1); int cons=0,cnt=0,j; for( j=idx;j<s.size() && cnt<=k;j++){ if(s[j]==s[idx]) cons++; else{ ans=min(ans,find(cons)+solve(s,k-cnt,j)); cnt++; } } if(cnt<=k) ans=min(ans,find(cons)+solve(s,k-cnt,j)); return dp[idx][k]=ans; } int getLengthOfOptimalCompression(string s, int k) { memset(dp,-1,size(dp)); return solve(s,k,0); } }; what is the error in my code

  • @nagasrisaichaitanyakolluri8173

    Thanks

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

    Wow very simply and beautifully explained!

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

    Thanks bro

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

    Thank you, well explained.

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

    Nice thumbnail ❤

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

    Very energetic and enthusiastic way of explaining the solution. Thanks much.

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

      I am glad you liked it ❤️

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

    Simplified and clear explanation.

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

    nice explanatory video

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

    Nice

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

    Bro, this was dope. Thanks a lot.

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

    Amazing Explanation, brooo!!! 💯💯

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

    Nice presentation

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

    Telegram Links: t.me/+FieKB7Ds6j02Y2Y1 t.me/+JU-ZF-oDjX4xYjBl

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

    The first approach is O(mlogm) m = no of batteries and the binary search approach is O(mlogk). It's given that k >> m. It seems that the frist one is better. Why use binary search?

  • @priyAGUPTA-kr7wb
    @priyAGUPTA-kr7wb Před 9 měsíci

    you are helping a lot but sometime your voice buffer so much and sound like not a ear friendly so plz improve your voice quality just a suggestion anyways you are doing great thanks for sharing :)

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

      Thank you for your feedback!! Will surely correct

  • @ShivamKumar-kd5iv
    @ShivamKumar-kd5iv Před 9 měsíci

    I wasnt able to think of 1D dp solution so I wrote 2D dp code and converted the dp array to an unordered map and combined the 2 states to a single string in the map , and got AC. will this be a valid solution in the interview ??

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

      Yes this will be valid!! However if you are in a interview the interviewer will guide or direct you towards a 2d array for mem. Once you have come up with a solution that gets accepted, just think if you can make it still better. I am pretty sure if you came up with hashmap, coming up with 2d array will be very easy for you.

    • @ShivamKumar-kd5iv
      @ShivamKumar-kd5iv Před 9 měsíci

      @@c0de_sutra initially I came up with 2D dp solution only but I got runtime as constrains for n was 10^6 and steps were 500 so my code was making a 2D array of about 5 * 10^8 size which is prohibited in c++ even if it is global array , I believe the limit is 10^7 for global arrays , hence I tried to reduce a state using map. Can this problem be solved only using 1 state i.e. steps parameter ? . I read the hint2 on leetcode for this question which said "Notice that the computational complexity does not depend of "arrlen".

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

    can we use recursive DP with Memoization (using a HashMap for storing values) for this problem?

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

      Yes, you can try that. But since all states will be visited, the hashmap will increase to same size.

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

    Sir, I thought about this problem like this: If I add up the totalTime and start with that: f(n,totalTime, T). If I went for not_take, totalTime will decrease by one and if I went for take, totalTime will increase by time[i]. If totalTime is greater than the start(T) then return 0 else return 1e9. Hence the dp will be [n+1][2*totalTime+1]. But it gives Memory Limit Exceeded. If I use your way which is [n][n+1], it will work. Mr. how should I know this is the correct way to solve starting from recursion? Thank you for your amazing videos bhaiya!!!