This video could not play here.
It may be members-only, region-restricted, or unavailable in embedded players.
Count subarrays with AND equal to min: why two pointers fail
The 4th problem in LeetCode Weekly Contest 528 asks you to count the subarrays whose AND equals their minimum. Before any code, narrow down the technique.
It's a count problem. Binary search and greedy don't solve counting, and brute force is too slow for these constraints. That leaves contribution technique, two pointers or DP, and DP over the index is O(N²).
Two pointers needs a pattern that holds as the window grows. Here both the min and the AND drop as you add elements, so a subarray can be valid, then invalid, then valid again. Two pointers can't handle that, so what's left is the contribution technique. The next Short shows how it works.
Full stream: https://youtu.be/e1MR7-WTA3s
#leetcode #competitiveprogramming #leetcodecontest #dsa #twopointers
Leave a like, comment, and subscribe for more.
Check out AlgoZenith: https://maang.in/
-----------------------------------------------
😃 ABOUT ME
I’m Vivek, an engineer, Ex-Googler, ICPC World Finalist turned educator, and founder of AlgoZenith. I’ve taught Data Structures, Algorithms, and Competitive Programming to over 3000+ students and worked with 10+ engineering colleges to bridge the gap between college learning and real-world tech careers. Through AlgoZenith, I help students crack top product-based companies and become industry-ready. On this channel, you’ll find videos on coding strategies, roadmaps, interview prep, problem-solving techniques, and everything you need to level up your software career. If that’s your thing, do subscribe and hit the bell icon so you don’t miss a thing 🙂
-----------------------------------------------
📲 SOCIALS
Instagram: https://www.instagram.com/vivekgupta.ai/ Twitter: https://x.com/vg19988 LinkedIn: https://www.linkedin.com/in/acraider/ Codechef (5 ⭐️): https://www.codechef.com/users/acraider Codeforces (Master, max. 2269): https://codeforces.com/profile/acraider
-----------------------------------------------
🏷️ TAGS
-----------------------------------------------
#️⃣ HASHTAGS