Smallest Subarrays With Maximum Bitwise OR | Detailed Explanation | Leetcode 2411 | codestorywithMIK

Subscribers:
112,000
Published on ● Video Link: https://www.youtube.com/watch?v=7ZOmJlTI2Z0



Duration: 0:00
9,707 views
489


Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A

How to check if kth bit of a number is set or not :    • DSA Shorts with MIK - 8  

Hi Everyone, this is the 27th video of our Playlist "Bit Manipulation : Popular Interview Problems".
Now we will be solving a good bit concept related problem - Smallest Subarrays With Maximum Bitwise OR | Detailed Explanation | Leetcode 2411 | codestorywithMIK

I will explain it in full detail so that it becomes easy to understand. Each line will be explained and you will know the WHY behind everything.

Problem Name : Smallest Subarrays With Maximum Bitwise OR | Detailed Explanation | Leetcode 2411 | codestorywithMIK
Company Tags : will update later
Code Github(C++ & JAVA) - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Bit_Magic/Smallest Subarrays With Maximum Bitwise OR.cpp
Leetcode Link - https://leetcode.com/problems/smallest-subarrays-with-maximum-bitwise-or/description/


My DP Concepts Playlist :    • Roadmap for DP | How to Start DP ? | Topic...  
My Graph Concepts Playlist :    • Graph Concepts & Qns - 1 : Graph will no m...  
My Segment Tree Concepts Playlist :    • Segment Tree | Introduction | Basics | Bui...  
My Recursion Concepts Playlist :    • Introduction | Recursion Concepts And Ques...  
Trie Playlist -    • Word Search II (Google, Amazon, Meta, Micr...  
Difference Array Technique: Concepts & Qns :    • Introduction | What | How | Difference Arr...  
Monotonic Data Structure Concepts & Qns :    • Monotonic Data Structures Concepts & Qns  
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel :    / @codestorywithmik  

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝


Video Summary :
The key idea is to compute, for each index, how far we need to go right to include all bits that could contribute to the maximum OR. We track the most recent index where each bit (0 to 30) was last seen set using setIndex. While iterating backward, we update the farthest point (j) we must include to ensure all significant bits are captured. The result at each index is simply the length from i to j. This way, we efficiently find the minimal subarray that gives the max OR at each position.


✨ Timelines✨
00:00 - Introduction
0:16 - Motivation
0:41 - Problem Explanation
4:30 - Thought Process
7:47 - Why do we need to see 32-bit representation ?
21:15 - Core Observation
23:22 - Why iterate from right to left ?
28:42 - Complete Dry Run
40:15 - Coding it up
43:27 - Time & Space Complexity


#MIK #mik #Mik
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik




Other Videos By codestorywithMIK


2025-08-08Unboxing My YouTube Silver Play Button | 100K Special Video | My Message To The Community | MIK
2025-08-08Work hard for them | codestorywithMIK
2025-08-07100K Special Video Coming Soon | codestorywithMIK
2025-08-07Find the Maximum Number of Fruits Collected | Recursion | Bottom Up | Leetcode 3363 | DP On Grids
2025-08-05Fruits Into Baskets II & III | Segment Tree Concepts & Qns | Video 13 | Leetcode 3477 | 3479 | MIK
2025-08-04Fruit Into Baskets | Simple Observation | Leetcode 904 | codestorywithMIK
2025-08-03Happy Friendship Day To All ❤️ | codestorywithMIK
2025-08-03Maximum Fruits Harvested After at Most K Steps | Detailed Explanation | Leetcode 2106 | MIK
2025-08-02Rearranging Fruits | Detailed Explanation | Minute Details | Leetcode 2561 | codestorywithMIK
2025-07-30Bitwise ORs of Subarrays | Detailed Explanation | Why Linear Time | Leetcode 898 | codestorywithMIK
2025-07-29Smallest Subarrays With Maximum Bitwise OR | Detailed Explanation | Leetcode 2411 | codestorywithMIK
2025-07-27Remembering where it all started from | codestorywithMIK
2025-07-26Count Hills and Valleys in an Array | Simple Explanation | Leetcode 2210 | codestorywithMIK
2025-07-26Maximize Subarrays After Removing One Conflicting Pair | Detailed Explanation | Leetcode 3480 | MIK
2025-07-24Maximum Unique Subarray Sum After Deletion | Constant Space | Leetcode 3487 | codestorywithMIK
2025-07-24Minimum Score After Removals on a Tree | Detailed Explanation | Leetcode 2322 | codestorywithMIK
2025-07-22Are bhai 🥺 | codestorywithMIK
2025-07-22Ever heard of Recursion Leap Of Faith | codestorywithMIK
2025-07-22That feeling ❤️🙏 | codestorywithMIK
2025-07-22Maximum Erasure Value | 2 Approaches | Leetcode 1695 | codestorywithMIK
2025-07-20Delete Duplicate Folders in System | Super Detailed Explanation | Leetcode 1948 | codestorywithMIK