Minimize XOR | 2 Detailed Approaches | Dry Runs | Leetcode 2429 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
Hi Everyone, this is the 24th video of our Playlist "Bit Manipulation : Popular Interview Problems".
We will solve a very good problem to practice bit Manipulation concepts - Minimize XOR | 2 Detailed Approaches | Dry Runs | Leetcode 2429 | codestorywithMIK
We will deep dive in minute details. The explanation will be detailed so that even beginners can understand it well.
Problem Name : Minimize XOR | 2 Detailed Approaches | Dry Runs | Leetcode 2429 | codestorywithMIK
Company Tags : will update later
Github Solutions Link (C++/Java) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Bit_Magic/Minimize XOR.cpp
Leetcode Link : https://leetcode.com/problems/minimize-xor
My DP Concepts Playlist : • Roadmap for DP | How to Start DP ? | ...
My Graph Concepts Playlist : • Graph Concepts & Qns - 1 : Graph will...
My Segment Tree Concepts Playlist : • Segment Tree | Introduction | Basics ...
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
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Video Summary :
Approach 1: Starting from num1 and then forming the result
The intuition is to start with num1 and modify its bits to match the required number of set bits (1s) in num2. If num1 has fewer set bits than required, unset bits are turned on starting from the least significant bit. Conversely, if num1 has more set bits, the most significant set bits are turned off. This ensures the result remains as close as possible to num1 while meeting the constraints.
Approach 2: Directly building the result
Here, the result is constructed from scratch by prioritizing the significant bits of num1. The algorithm first sets the highest significant bits of num1 to ensure minimal difference from it. If additional bits are needed, it sets unset bits starting from the least significant bit. This approach focuses on building a result with minimal XOR to num1 while achieving the required set bits.
✨ Timelines✨
00:00 - Introduction
00:28 - Motivation
02:04 - Problem Explanation
05:29 - Approach-1 Thought Process
16:55 - How to set a bit position ?
18:54 - How to unset a bit position ?
21:52 - How to check if a bit position is set ?
25:13 - Coding Approach-1 in C++
31:43 - Coding Approach-1 in JAVA
35:51 - Approach-2 Thought Process
45:56 - Coding Approach-2 in C++
50:10 - Coding Approach-2 in JAVA
#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