Count Number of Maximum Bitwise-OR Subsets | Simplest Approach |Leetcode 2044 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 116th Video of our Playlist "Array 1D/2D : Popular Interview Problems" by codestorywithMIK
My Subsets Video - • Subsets | Simple Story To Code | Leet...
In this video we will try to solve a medium-easy Array subsets based Problem : Count Number of Maximum Bitwise-OR Subsets | Simplest Approach |Leetcode 2044 | codestorywithMIK
We will solve it using a simple subsets concept.
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Count Number of Maximum Bitwise-OR Subsets | Simplest Approach |Leetcode 2044 | codestorywithMIK
Company Tags : will update
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Arrays/Count Number of Maximum Bitwise-OR Subsets.cpp
Leetcode Link : https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets
My DP Concepts Playlist : • Roadmap for DP | How to Start DP ? | ...
My Graph Concepts Playlist : • Graph Concepts & Qns - 1 : Graph will...
My Recursion Concepts Playlist : • Introduction | Recursion Concepts And...
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
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Summary :
Approach-1 (Simple Recursion):
This approach uses recursion to explore all possible subsets of the array. It calculates the bitwise OR of each subset and counts how many subsets have an OR value equal to the maximum OR value of the entire array.
At each step, the function either includes or excludes the current element (nums[idx]), recursively calculates the OR value, and checks if it matches the maximum OR.
Time Complexity: O(2^n) since it explores all subsets.
Space Complexity: O(1) (excluding the recursion stack).
Approach-2 (Memoization):
This is an optimized version of the recursive approach, where we store the results of subproblems (using a memoization table) to avoid recalculating the OR values for the same states.
The table t[idx][currOr] stores the result of subsets from index idx onward with the current OR value currOr. This avoids recomputation and speeds up the process.
Time Complexity: O(n * maxOr) where maxOr is the maximum OR value achievable.
Space Complexity: O(n * maxOr) due to the memoization table.
✨ Timelines✨
00:00 - Introduction
#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