codingMohan
codingMohan
  • 373
  • 488 493
3297. Count Substrings That Can Be Rearranged to Contain a String I | Weekly Leetcode 416
Segment Tree Series - bit.ly/segment-trees
DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html
Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html
*************************************************
Contest Link - leetcode.com/contest/weekly-contest-416
Problem Link - leetcode.com/contest/weekly-contest-416/problems/count-substrings-that-can-be-rearranged-to-contain-a-string-ii/
Solution - leetcode.com/problems/count-substrings-that-can-be-rearranged-to-contain-a-string-i/solutions/5819091/video-explanation-journey-from-o-n-n-c-o-n-c-logn-o-n-c-o-n/
*************************************************
Timestamps -
00:00 - Agenda
00:35 - Problem Description
02:25 - [Brute Force] Algorithm
04:58 - [Brute Force] Pseudo code & Time Complexity
06:35 - [Optimization 1] Reuse the frequency -- O(N*N*C)
07:35 - [Optimization 2] Breaking at just 1st "r" -- O(N*N*C)
11:18 - [Optimization 3] Intuition of Binary search for "r"
15:20 - [Optimization 3] Computing whether [l, r] is valid in O(C)
21:12 - [Optimization 3] Pseudo code & Time Complexity
24:41 - [Optimization 4] Intuition to 2 Pointers
32:30 - [Optimization 4] Pseudo code & Time Complexity
*************************************************
Interview Experiences Playlists -
Microsoft - ua-cam.com/play/PL9TOCZErLZcOsCBZPQ3uIMzak6gQWG_Kp.html
Amazon - ua-cam.com/play/PL9TOCZErLZcMFSmxoEpNBxvQfWOgRmsfX.html
D.E.Shaw - ua-cam.com/play/PL9TOCZErLZcM8nwVeW4d7JyxcpH175IZ1.html
Linkedin - ua-cam.com/play/PL9TOCZErLZcMN56ITB1IkNUs10QnaEyAe.html
Facebook - ua-cam.com/play/PL9TOCZErLZcNIcaPV8WeHdXHPgAstBf2E.html
*********************************************************************
Please show support and subscribe if you find the content useful.
Переглядів: 1 059

Відео

3298. Count Substrings That Can Be Rearranged to Contain a String II | Weekly Leetcode 416
Переглядів 6652 місяці тому
Segment Tree Series - bit.ly/segment-trees DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-416 Problem Link - leetcode.com/contest/weekly-contest-416/problems/count-substrings-that-can-be-rearranged-to-contain-a-string-ii/ Solution - leetcode.com/pr...
3287. Find the Maximum Sequence Value of Array | Leetcode Biweekly 139
Переглядів 1,5 тис.3 місяці тому
Segment Tree Series - bit.ly/segment-trees Contest Link - leetcode.com/contest/biweekly-contest-139/ Problem Link - leetcode.com/contest/biweekly-contest-139/problems/find-the-maximum-sequence-value-of-array/description/ Solution - leetcode.com/problems/find-the-maximum-sequence-value-of-array/solutions/5790538/video-explanation-dissecting-problem-step-by-step-with-intuition-why-not-recursion/ ...
3291. Minimum Number of Valid Strings to Form Target I | Weekly Leetcode 415
Переглядів 1,2 тис.3 місяці тому
Segment Tree Series - bit.ly/segment-trees DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html Contest Link - leetcode.com/contest/weekly-contest-415 Problem Link - leetcode.com/contest/weekly-contest-415/problems/minimum-number-of-valid-strings-to-form-target-i/ Solution - leetcode.com/problems/minimum-number-of-valid-strings-to-form-target-ii/solutions/5789212/video-explanat...
3292. Minimum Number of Valid Strings to Form Target II | Weekly Leetcode 415 | Z-Algorithm
Переглядів 9843 місяці тому
Segment Tree Series - bit.ly/segment-trees Similar Hashing Problems - 1. ua-cam.com/video/8kMq8WyCpj0/v-deo.html 2. ua-cam.com/video/1thnThrIzwg/v-deo.html 3. ua-cam.com/video/hRd3ZlTBkEs/v-deo.html DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Z-Algorithm - cp-algorithms.com/string/z-function.htm...
3283. Maximum Number of Moves to Kill All Pawns | Weekly Leetcode 414
Переглядів 7763 місяці тому
Segment Tree Series - bit.ly/segment-trees DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-414 Problem Link - leetcode.com/contest/weekly-contest-414/problems/maximum-number-of-moves-to-kill-all-pawns/description/ Solution - leetcode.com/problems/ma...
3277. Maximum XOR Score Subarray Queries | Weekly Leetcode 413
Переглядів 9943 місяці тому
Segment Tree Series - bit.ly/segment-trees DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-413 Problem Link - leetcode.com/contest/weekly-contest-413/problems/maximum-xor-score-subarray-queries/ Solution - leetcode.com/problems/maximum-xor-score-sub...
3276. Select Cells in Grid With Maximum Score | Weekly Leetcode 413
Переглядів 1,6 тис.3 місяці тому
Segment Tree Series - bit.ly/segment-trees DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-413 Problem Link - leetcode.com/contest/weekly-contest-413/problems/select-cells-in-grid-with-maximum-score/ Solution - leetcode.com/problems/select-cells-in-...
3267. Count Almost Equal Pairs II | Weekly Leetcode 412
Переглядів 7093 місяці тому
Segment Tree Series - bit.ly/segment-trees DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-412 Problem Link - leetcode.com/contest/weekly-contest-412/problems/count-almost-equal-pairs-ii/ Solution - leetcode.com/problems/count-almost-equal-pairs-ii/...
3266. Final Array State After K Multiplication Operations II | Weekly Leetcode 412
Переглядів 1,5 тис.3 місяці тому
Segment Tree Series - bit.ly/segment-trees DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-412 Problem Link - leetcode.com/contest/weekly-contest-412/problems/final-array-state-after-k-multiplication-operations-ii/ Solution - leetcode.com/problems/f...
3250. Find the Count of Monotonic Pairs I | Weekly Leetcode 410
Переглядів 1,5 тис.4 місяці тому
Segment Tree Series - bit.ly/segment-trees DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-409 Problem Link -leetcode.com/contest/weekly-contest-410/problems/find-the-count-of-monotonic-pairs-i/ Solution - leetcode.com/problems/find-the-count-of-mon...
3251. Find the Count of Monotonic Pairs II | Weekly Leetcode 410
Переглядів 2,1 тис.4 місяці тому
Segment Tree Series - bit.ly/segment-trees DP Playlist - ua-cam.com/play/PL9TOCZErLZcNxIHWVRcJbVTvgRgLFcgHC.html Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-409 Problem Link -leetcode.com/contest/weekly-contest-410/problems/find-the-count-of-monotonic-pairs-ii/ Solution - leetcode.com/problems/find-the-count-of-mo...
3245. Alternating Groups III | Weekly Leetcode 409
Переглядів 1,5 тис.4 місяці тому
Segment Tree Series - bit.ly/segment-trees Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-409 Problem Link - leetcode.com/contest/weekly-contest-409/problems/alternating-groups-iii/description/ Solution - leetcode.com/problems/alternating-groups-iii/solutions/5585945/video-explanation-starting-from-brute-force-and-op...
3244. Shortest Distance After Road Addition Queries II | Weekly Leetcode 409
Переглядів 1,3 тис.4 місяці тому
Segment Tree Series - bit.ly/segment-trees Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-409 Problem Link - leetcode.com/contest/weekly-contest-409/problems/shortest-distance-after-road-addition-queries-ii/description/ Solution - leetcode.com/problems/shortest-distance-after-road-addition-queries-ii/solutions/558407...
3235. Check if the Rectangle Corner Is Reachable | Weekly Leetcode 408
Переглядів 1,2 тис.4 місяці тому
Segment Tree Series - bit.ly/segment-trees Hashing Playlist - ua-cam.com/play/PL9TOCZErLZcPVi_Nt-bHCwH9GtV-nz93c.html Contest Link - leetcode.com/contest/weekly-contest-408 Problem Link - leetcode.com/contest/weekly-contest-408/problems/check-if-the-rectangle-corner-is-reachable/ Solution - leetcode.com/problems/check-if-the-rectangle-corner-is-reachable/solutions/5547478/video-explanation-intu...
3234. Count the Number of Substrings With Dominant Ones | Weekly Leetcode 408
Переглядів 5 тис.4 місяці тому
3234. Count the Number of Substrings With Dominant Ones | Weekly Leetcode 408
3225. Maximum Score From Grid Operations | Leetcode Biweekly 135
Переглядів 1,8 тис.4 місяці тому
3225. Maximum Score From Grid Operations | Leetcode Biweekly 135
3229. Minimum Operations to Make Array Equal to Target | Weekly Leetcode 407
Переглядів 9064 місяці тому
3229. Minimum Operations to Make Array Equal to Target | Weekly Leetcode 407
3218. Minimum Cost for Cutting Cake I | Weekly Leetcode 406
Переглядів 4785 місяців тому
3218. Minimum Cost for Cutting Cake I | Weekly Leetcode 406
3219. Minimum Cost for Cutting Cake II | Weekly Leetcode 406
Переглядів 4375 місяців тому
3219. Minimum Cost for Cutting Cake II | Weekly Leetcode 406
3213. Construct String with Minimum Cost | Weekly Leetcode 405
Переглядів 1,2 тис.5 місяців тому
3213. Construct String with Minimum Cost | Weekly Leetcode 405
3209. Number of Subarrays With AND Value of K | Leetcode Biweekly 134
Переглядів 7705 місяців тому
3209. Number of Subarrays With AND Value of K | Leetcode Biweekly 134
3212. Count Submatrices With Equal Frequency of X and Y | Weekly Leetcode 405
Переглядів 1,3 тис.5 місяців тому
3212. Count Submatrices With Equal Frequency of X and Y | Weekly Leetcode 405
3202. Find the Maximum Length of Valid Subsequence II | Weekly Leetcode 404
Переглядів 1,5 тис.5 місяців тому
3202. Find the Maximum Length of Valid Subsequence II | Weekly Leetcode 404
3203. Find Minimum Diameter After Merging Two Trees | Weekly Leetcode 404
Переглядів 6225 місяців тому
3203. Find Minimum Diameter After Merging Two Trees | Weekly Leetcode 404
3197. Find the Minimum Area to Cover All Ones II | Weekly Leetcode 403
Переглядів 1,1 тис.5 місяців тому
3197. Find the Minimum Area to Cover All Ones II | Weekly Leetcode 403
3186. Maximum Total Damage With Spell Casting | Weekly Leetcode 402
Переглядів 9036 місяців тому
3186. Maximum Total Damage With Spell Casting | Weekly Leetcode 402
3187. Peaks in Array | Weekly Leetcode 402
Переглядів 5976 місяців тому
3187. Peaks in Array | Weekly Leetcode 402
3170. Lexicographically Minimum String After Removing Stars | Weekly Leetcode 400
Переглядів 4306 місяців тому
3170. Lexicographically Minimum String After Removing Stars | Weekly Leetcode 400
3171. Find Subarray With Bitwise AND Closest to K | 2 different Approaches | Weekly Leetcode 400
Переглядів 1,3 тис.6 місяців тому
3171. Find Subarray With Bitwise AND Closest to K | 2 different Approaches | Weekly Leetcode 400

КОМЕНТАРІ

  • @princekumar-xe9ex
    @princekumar-xe9ex 2 дні тому

    Really Helpful

  • @veljkomladenovic8397
    @veljkomladenovic8397 4 дні тому

    Very nice explenation as always

  • @bec_Divyansh
    @bec_Divyansh 5 днів тому

    Greatest Explanation ❤

  • @anshyadav2225
    @anshyadav2225 6 днів тому

    can this be solved using segment trees?

  • @NitinSingh0108
    @NitinSingh0108 7 днів тому

    Thanks Sir🙏

  • @dibyendusaha1295
    @dibyendusaha1295 16 днів тому

    public class Solution { public long IncremovableSubarrayCount(int[] nums) { int n=nums.Length; int left=0; for(left=0;left<n-1;left++) { if(nums[left]>=nums[left+1]) { break; } } if(left==n-1) return (long) n*(n+1)/2; int right=n-1; while(nums[right]>nums[right-1]) { right--; } long count=n-right+1; for(int i=0,j=right;i<=left;i++) { while(j<n && nums[j]<=nums[i]) { j++; } count+=n-j+1; } return count; } }

  • @angus10292
    @angus10292 19 днів тому

    subscribed and liked! Your channel needs more traffic! Cheers bro

  • @AMITSHARMA-oh1nq
    @AMITSHARMA-oh1nq 20 днів тому

    Can you provide the google doc link which you show initially in vdo

  • @AMITSHARMA-oh1nq
    @AMITSHARMA-oh1nq 20 днів тому

    How on earth these gems are so underrated. This channwl is Goldmine for someone who is trying to learn computational problem solving - kudos

  • @tempbot7190
    @tempbot7190 24 дні тому

    Bro! Crazy solution and explanation Please continue to this great thing of doing Multiple approaches

  • @manrajsingh4644
    @manrajsingh4644 24 дні тому

    Loved your approach towards questions !!!!

  • @sridharaddagatla
    @sridharaddagatla 27 днів тому

    Thanks so much. Really simplified it.

  • @VineetDixit
    @VineetDixit Місяць тому

    I HAVENT SEEN ANY GOOD CHANNEL FOR LEETCODE GRIND THAN THIS,THANK YOU SO MUCH FOR YOUR EFFORTS

  • @josephaj8310
    @josephaj8310 Місяць тому

    Bro, what will be the dp approach for this?

  • @nikhilprakash729
    @nikhilprakash729 Місяць тому

    Awesome Solution sir...

  • @prakhargarg4166
    @prakhargarg4166 Місяць тому

    Thank you, sir

  • @prakhargarg4166
    @prakhargarg4166 Місяць тому

    Thank you, so much, sir

  • @prakhargarg4166
    @prakhargarg4166 Місяць тому

    I solved just using a single loop: "class Solution { public long maximumValueSum(int[] arr, int k, int[][] edges) { int n = arr.length; int[] brr = new int[n]; for(int i = 0; i < n; i++) brr[i] = (arr[i] ^ k) - arr[i]; Arrays.sort(brr); for(int i = 0; i < n / 2; i++){ int temp = brr[i]; brr[i] = brr[n - i - 1]; brr[n - i - 1] = temp; } // System.out.println("Printing brr: "); // for(int i = 0; i < n; i++) System.out.print(brr[i] + " "); // System.out.println(" ------------------------"); long ans = 0; for(int i = 0; i < n; i++){ if(brr[i] > 0) ans += brr[i]; else { if(i % 2 == 1){ long mySum = brr[i] + brr[i - 1]; if(mySum > 0) ans += brr[i]; else ans -= brr[i - 1]; } else{ break; } } } if(n % 2 == 1 && brr[n - 1] > 0) ans -= brr[n - 1]; long initSum = 0; for(long x: arr) initSum += x; // 263 // System.out.println("initSum: " + initSum); return initSum + ans; } }"

  • @jayantbelwanshi2625
    @jayantbelwanshi2625 Місяць тому

    🙌🙌🙌

  • @prakhargarg4166
    @prakhargarg4166 Місяць тому

    Thank you, sir

  • @prakhargarg4166
    @prakhargarg4166 Місяць тому

    Thank you sir

  • @prakhargarg4166
    @prakhargarg4166 Місяць тому

    Did using max segment tree and min segment tree and binary serach

  • @prakhargarg4166
    @prakhargarg4166 Місяць тому

    Thank you, sir

  • @prakhargarg4166
    @prakhargarg4166 Місяць тому

    Best explainer over yt. Love to watch your videos. Thank you, sir !!!

  • @pratyushpriyamkuanr273
    @pratyushpriyamkuanr273 Місяць тому

    Best solution video I have seen so far. Sir please do find some time to create playlists for other concepts. Thank you for your hard work.

  • @yashsawalkar646
    @yashsawalkar646 Місяць тому

    The DSU solution is so genius

  • @prakhargarg4166
    @prakhargarg4166 Місяць тому

    Thank you sir

  • @joshianurag6211
    @joshianurag6211 Місяць тому

    I did not understand, can you please explain in Hindi.

  • @im_ykp
    @im_ykp Місяць тому

    Nicely Explained

  • @lambukushireddy424
    @lambukushireddy424 Місяць тому

    QUALITY>>>

  • @aakashparmar560
    @aakashparmar560 Місяць тому

    Great explanation,

  • @kushalkollu8628
    @kushalkollu8628 Місяць тому

    very impressive explanation. keep doing these videos

  • @Anonymous____________A721
    @Anonymous____________A721 Місяць тому

    Wowwwww

  • @Anonymous____________A721
    @Anonymous____________A721 Місяць тому

    Lol This is straightforward How is this difficult

  • @gauravmandal01
    @gauravmandal01 Місяць тому

    @codingmohan I am not able to understand about one thing what about the cases where the optimal doesn't have first factory

  • @vamsikrishnagannamaneni912
    @vamsikrishnagannamaneni912 Місяць тому

    39:28 Why will there be k/2 ones to left and (k/2)-1 to right?

  • @aakashparmar560
    @aakashparmar560 Місяць тому

    Top quality content

  • @shakti5521
    @shakti5521 Місяць тому

    The code is not handling the test cases updated by leetcode

  • @aakashparmar560
    @aakashparmar560 Місяць тому

    Great explanation

  • @dudeyouhavenoidea
    @dudeyouhavenoidea Місяць тому

    wow, this makes so much sense now , thank you

  • @imsntoo
    @imsntoo Місяць тому

    Could someone provide me with some problems that can be solved using this technique?

  • @sravantipris3544
    @sravantipris3544 Місяць тому

    why this depth[st[root -> val]] = height instead of depth[root -> val] = height explain please any one explain further clearly why we do this

  • @SD-vk3ko
    @SD-vk3ko Місяць тому

    HUGE Respect to you

  • @ravenx
    @ravenx Місяць тому

    Wow i learned somthing new euler tour thx man

  • @abanikumar8574
    @abanikumar8574 Місяць тому

    You are not explaing the question very well and not take at least 2 example for better understanding. Take it as a feedback .

  • @vishalgadade1585
    @vishalgadade1585 Місяць тому

    Why you are doing aaa aaa aaa in between it's irritating