Find Subarray With Bitwise AND Closest to K | Sliding Window | Leetcode 3171 | codestorywithMIK

  Рет қаралды 3,325

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 49
@codestorywithMIK
@codestorywithMIK 7 ай бұрын
This is lengthy just because I have added detailed and minute details for beginners. But if you got the idea in the middle, feel free to stop in the middle and try to code as per the understanding. Hope it helps ❤❤❤❤
@rugung1381
@rugung1381 7 ай бұрын
please make a videos on this Qn bhaiya🙏 3181. Maximum Total Reward Using Operations II last LC contest ke DP optimisation ke hai
@aws_handles
@aws_handles 6 ай бұрын
Thanks a lot
@gamersgame43
@gamersgame43 Ай бұрын
only for this video, I learned a new data structure bitmap, and been able to solve the new question which has been changed in leetcode from AND operation to OR operation
@pranavvenkat7971
@pranavvenkat7971 7 ай бұрын
Very detailed explanation really enjoyed keep uploading video daily ...your video daily reminder for me to learn DSA daily
@gui-codes
@gui-codes 7 ай бұрын
please keep posting such long and detailed videos. these are hidden gems. Thanks a lot
@anjanasahay2172
@anjanasahay2172 7 ай бұрын
Please keep on sharing new methods that will help us....with hard problems??? Especially the bitwise manipulation in the preSum types❤❤
@25-cse-csmohitkumarmandal59
@25-cse-csmohitkumarmandal59 7 ай бұрын
Eagerly waiting for this video ❤ thanks 🙏
@molyoxide8358
@molyoxide8358 7 ай бұрын
1st comment. Bro pls make a playlist on Bit-Manipulation
@Rajan-xv9cz
@Rajan-xv9cz 7 ай бұрын
best explanation really enjoyed♥♥♥
@aws_handles
@aws_handles 6 ай бұрын
Itna detail paid course me bhi nai milta hoga thanks mik
@22gauravkumar70
@22gauravkumar70 7 ай бұрын
bhaiya please segment tree sikha do pls , 1 saal se try kr raha hun sikhne ka aap hi sikha skte ho. ek 3-4 ghnte ki video bna do , 5-6 questions krwa do along with basic code , please bhaiya
@bidishadas832
@bidishadas832 6 ай бұрын
Excellent explanation.
@jailudhani8841
@jailudhani8841 3 ай бұрын
Is problem statement changed, Previously it was for AND, now I am seeing it is for OR.
@ronniieeestar6274
@ronniieeestar6274 7 ай бұрын
Hi @codestorywithMIK leetcode changed this question previously it is AND of subarray now it is OR of subarray
@tanmaykumar4081
@tanmaykumar4081 7 ай бұрын
bhaiya ab please 2,3,4 problem no. of contest upload karna start kar dijiyega na every week it will be really helpful. If you could find time
@mohd.vaseem7410
@mohd.vaseem7410 7 ай бұрын
amazing eleplanation
@thefinalfit
@thefinalfit 7 ай бұрын
Thanks a lot for detailing every point
@shashiraj6226
@shashiraj6226 7 ай бұрын
i tried to understand this question on many other channel but i could not get it. Thank you very much for this video and amazing explanation.💜
@pokeindia5361
@pokeindia5361 7 ай бұрын
@shashiraj6226 is it contest q??
@shashiraj6226
@shashiraj6226 7 ай бұрын
@@pokeindia5361 yes last question of leetcode contest 400
@rev_krakken70
@rev_krakken70 7 ай бұрын
Hi @codestorywithMIK. I skimmed through some of the solutions with better time complexity, and some of them were using dp with hashset. Can you make one video of this same problem using that approach?
@jeehub041
@jeehub041 7 ай бұрын
Superb explaination sir but itna sab contest me figure out karna mushkil hota
@codestorywithMIK
@codestorywithMIK 7 ай бұрын
I agree but with practising problems like the more and more, we will be able to implement it during interviews/contests in given time frame ❤️
@dayashankarlakhotia4943
@dayashankarlakhotia4943 7 ай бұрын
Good explanation 👏 ❤
@gauravbanerjee2898
@gauravbanerjee2898 7 ай бұрын
Thanks a lot bhaiya ❤❤
@iWontFakeIt
@iWontFakeIt 7 ай бұрын
maine binary search + prefix sum se solve kiya tha contest k time pe, kyuki wahi mera dimag me chamka tha
@Lakshya-f4l
@Lakshya-f4l 4 ай бұрын
Can you explain the intuition behind your solution?
@FanIQQuiz
@FanIQQuiz 7 ай бұрын
Netflix ❌ MIK’s Long videos ✅
@English_Vinglish-c9o
@English_Vinglish-c9o 7 ай бұрын
@codestorywithMIK in brute force shouldnt the loop be from j=i instead of j=0?
@pokeindia5361
@pokeindia5361 7 ай бұрын
Bhaiya longest valid parantheses q bataiye please..... Ye interview k liye bhi important h..... Please bhaiya
@ramankr0022
@ramankr0022 7 ай бұрын
Thank you
@Ronakrewar
@Ronakrewar 6 ай бұрын
we can use map approch
@meme-ku1vs
@meme-ku1vs 7 ай бұрын
thanks
@25-cse-csmohitkumarmandal59
@25-cse-csmohitkumarmandal59 7 ай бұрын
Mere brute force 806 kuch test case pass kiye the 😅
@pokeindia5361
@pokeindia5361 7 ай бұрын
Ye contest ka q h kya??
@25-cse-csmohitkumarmandal59
@25-cse-csmohitkumarmandal59 7 ай бұрын
@@pokeindia5361 yes
@Sumit-wy4zp
@Sumit-wy4zp 7 ай бұрын
Yes
@Piyush-yp2po
@Piyush-yp2po 7 ай бұрын
What about nand? (& ~a)?
@HarshPal-i5i
@HarshPal-i5i 7 ай бұрын
hey can you provide your slide also ..... if it is possible
@shivam875S
@shivam875S 4 ай бұрын
code is giving wrong output plzz check it sir i think leetcode change the testcase
@GR8_Impact
@GR8_Impact 7 ай бұрын
Why this Question got changed from Leetcode to Bitwise OR ? I was thinking why the code is not working 😁 Modified code for Bitwise OR class Solution { public: void updateFreq(int op, int val, int* freqBits) { int i = 0; while (val > 0) { if ((val & 1)) { freqBits[i] += op; } val >>= 1; i++; } } int minimumDifference(vector& nums, int k) { ios_base::sync_with_stdio(false); int freqBits[32] = {0}; int n = nums.size(); int i = 0; int j = 0; int windowOR = 0; int result = INT_MAX; while (j < n) { windowOR = windowOR | nums[j]; updateFreq(1, nums[j], freqBits); result = min(result, abs(k - windowOR)); if (windowOR < k) { j++; } else if (windowOR == k) { return 0; } else { while (i < j && windowOR > k) { updateFreq(-1, nums[i], freqBits); i++; windowOR = 0; for (int b = 0; b < 32; b++) { if (freqBits[b] > 0) { windowOR = windowOR | (1
@SaranshKasliwal
@SaranshKasliwal 6 ай бұрын
or use this more cleaner code class Solution { public: void updateFreq(int op,int val,int *freqBits){ int i=0; while(val>0){ if(val & 1){//if the rightmost bit is 1 freqBits[i]+=op; //1 it will increament,-1 in will decrement } val>>=1; i++; } } int minimumDifference(vector& nums, int k) { int n=nums.size(); int freqBits[32]={0}; int i=0,j=0; int OR=0; int res=INT_MAX; while(j
@aizad786iqbal
@aizad786iqbal 7 ай бұрын
slack ke messages aa rahe hai :D
@nish0798
@nish0798 7 ай бұрын
BRO PLEASE ANSWER THIS QUESTION QUESTION IS IF WE CAN FORM TARGET STRING FROM ARRYA ELEMENTS import java.util.ArrayList; public class Solution { static ArrayList res = new ArrayList(); // Not used in this version public static void main(String[] args) { String[] arr = {"os","mn","pqr","qr"}; String t = "pqros"; //THIS SHOULD RETURN TRUE BCOZ PQR+OS is forming target but it is giivng false should return true technically String sofar = ""; ArrayList l = new ArrayList(); System.out.println(canconst(arr, t, sofar, 0, l)); } public static boolean canconst(String[] arr, String t, String sofar, int idx, ArrayList l) { if(sofar.equals(t)) { return true; } if (idx >= arr.length) { return false; } // Try appending each string from arr to sofar and recursively check if (canconst(arr, t, sofar + arr[idx], idx+1 , l)) { return true; } return canconst(arr, t, sofar, idx + 1, l); } } //THIS SHOULD RETURN TRUE BCOZ PQR+OS is forming target but it is giivng false should return true technically this code is only giivng correct output if the we are checking the idx elements sequence wise why so please answer what changes should i make in my code so that it works galti pakad nai aa rahi please help bhai do ghante ho gaye hit and trial kar raha hu doubt clear kardo aisa kyu horaha hai
@RamanKumar-gt8nm
@RamanKumar-gt8nm 2 ай бұрын
@codestorywithMik this question statement is chagned to the Or and ihave tried with the reversed logic can you please make a video on it becuase it is unable to submit import java.util.Arrays; class Solution { private void updateFreq(int op, int val, int[] freqBits) { int i = 0; while (val > 0) { if ((val & 1) == 1) { freqBits[i] += op; } val >>= 1; i++; } } public int minimumDifference(int[] nums, int k) { int n = nums.length; if (n == 1) { return Math.abs(nums[0] - k); } int[] freqBits = new int[32]; Arrays.fill(freqBits, 0); int i = 0; int j = 0; int windowOr = 0; int result = Integer.MAX_VALUE; while (j < n) { windowOr |= nums[j]; updateFreq(1, nums[j], freqBits); result = Math.min(result, Math.abs(k - windowOr)); if (windowOr < k) { j++; } else if (windowOr == k) { return 0; } else { while (i k) { updateFreq(-1, nums[i], freqBits); i++; windowOr = 0; for (int b = 0; b < 32; b++) { if (freqBits[b] > 0) { windowOr |= (1
@anshtanwar1813
@anshtanwar1813 7 ай бұрын
✌🐱
@yatri6329
@yatri6329 7 ай бұрын
Bro left ya right se remove krna hoga ye depend krega Array sorted hone p ??
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 769 М.
I Sent a Subscriber to Disneyland
0:27
MrBeast
Рет қаралды 104 МЛН
Counter-Strike 2 - Новый кс. Cтарый я
13:10
Marmok
Рет қаралды 2,8 МЛН
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН
7 Outside The Box Puzzles
12:16
MindYourDecisions
Рет қаралды 94 М.
[Golang] 001 - My Introduction
4:35
Go With Habib
Рет қаралды 3,2 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 716 М.
Сборник Эксклюзивов 2024 - Уральские Пельмени
1:33:24
Уральские Пельмени
Рет қаралды 1,1 МЛН
I Sent a Subscriber to Disneyland
0:27
MrBeast
Рет қаралды 104 МЛН