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

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

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 48
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
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 5 ай бұрын
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 5 ай бұрын
Thanks a lot
@pranavvenkat7971
@pranavvenkat7971 5 ай бұрын
Very detailed explanation really enjoyed keep uploading video daily ...your video daily reminder for me to learn DSA daily
@gui-codes
@gui-codes 5 ай бұрын
please keep posting such long and detailed videos. these are hidden gems. Thanks a lot
@anjanasahay2172
@anjanasahay2172 5 ай бұрын
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 5 ай бұрын
Eagerly waiting for this video ❤ thanks 🙏
@aws_handles
@aws_handles 5 ай бұрын
Itna detail paid course me bhi nai milta hoga thanks mik
@22gauravkumar70
@22gauravkumar70 5 ай бұрын
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
@molyoxide8358
@molyoxide8358 5 ай бұрын
1st comment. Bro pls make a playlist on Bit-Manipulation
@Rajan-xv9cz
@Rajan-xv9cz 5 ай бұрын
best explanation really enjoyed♥♥♥
@bidishadas832
@bidishadas832 5 ай бұрын
Excellent explanation.
@shashiraj6226
@shashiraj6226 5 ай бұрын
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 5 ай бұрын
@shashiraj6226 is it contest q??
@shashiraj6226
@shashiraj6226 5 ай бұрын
@@pokeindia5361 yes last question of leetcode contest 400
@jailudhani8841
@jailudhani8841 Ай бұрын
Is problem statement changed, Previously it was for AND, now I am seeing it is for OR.
@ugcwithaddi
@ugcwithaddi 5 ай бұрын
Thanks a lot for detailing every point
@jeehub041
@jeehub041 5 ай бұрын
Superb explaination sir but itna sab contest me figure out karna mushkil hota
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
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 ❤️
@mohd.vaseem7410
@mohd.vaseem7410 5 ай бұрын
amazing eleplanation
@tanmaykumar4081
@tanmaykumar4081 5 ай бұрын
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
@gauravbanerjee2898
@gauravbanerjee2898 5 ай бұрын
Thanks a lot bhaiya ❤❤
@rev_krakken70
@rev_krakken70 5 ай бұрын
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?
@ramankr0022
@ramankr0022 5 ай бұрын
Thank you
@dayashankarlakhotia4943
@dayashankarlakhotia4943 5 ай бұрын
Good explanation 👏 ❤
@ronniieeestar6274
@ronniieeestar6274 5 ай бұрын
Hi @codestorywithMIK leetcode changed this question previously it is AND of subarray now it is OR of subarray
@iWontFakeIt
@iWontFakeIt 5 ай бұрын
maine binary search + prefix sum se solve kiya tha contest k time pe, kyuki wahi mera dimag me chamka tha
@Lakshya-f4l
@Lakshya-f4l 2 ай бұрын
Can you explain the intuition behind your solution?
@thekindspill
@thekindspill 5 ай бұрын
Netflix ❌ MIK’s Long videos ✅
@English_Vinglish-c9o
@English_Vinglish-c9o 5 ай бұрын
@codestorywithMIK in brute force shouldnt the loop be from j=i instead of j=0?
@meme-ku1vs
@meme-ku1vs 5 ай бұрын
thanks
@25-cse-csmohitkumarmandal59
@25-cse-csmohitkumarmandal59 5 ай бұрын
Mere brute force 806 kuch test case pass kiye the 😅
@pokeindia5361
@pokeindia5361 5 ай бұрын
Ye contest ka q h kya??
@25-cse-csmohitkumarmandal59
@25-cse-csmohitkumarmandal59 5 ай бұрын
@@pokeindia5361 yes
@Sumit-wy4zp
@Sumit-wy4zp 5 ай бұрын
Yes
@Ronakrewar
@Ronakrewar 4 ай бұрын
we can use map approch
@pokeindia5361
@pokeindia5361 5 ай бұрын
Bhaiya longest valid parantheses q bataiye please..... Ye interview k liye bhi important h..... Please bhaiya
@Piyush-yp2po
@Piyush-yp2po 5 ай бұрын
What about nand? (& ~a)?
@HarshPal-i5i
@HarshPal-i5i 5 ай бұрын
hey can you provide your slide also ..... if it is possible
@shivam875S
@shivam875S 3 ай бұрын
code is giving wrong output plzz check it sir i think leetcode change the testcase
@aizad786iqbal
@aizad786iqbal 5 ай бұрын
slack ke messages aa rahe hai :D
@GR8_Impact
@GR8_Impact 5 ай бұрын
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 4 ай бұрын
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
@RamanKumar-gt8nm
@RamanKumar-gt8nm 23 күн бұрын
@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
@nish0798
@nish0798 5 ай бұрын
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
@anshtanwar1813
@anshtanwar1813 5 ай бұрын
✌🐱
@yatri6329
@yatri6329 5 ай бұрын
Bro left ya right se remove krna hoga ye depend krega Array sorted hone p ??
C Programming Tutorial for Beginners
3:46:13
freeCodeCamp.org
Рет қаралды 14 МЛН
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2,1 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 183 МЛН
Errichto Stream, POI 22/1
3:55:08
Errichto Algorithms
Рет қаралды 171 М.
Complete Dynamic Programming Practice - Noob to Expert | Topic Stream 1
3:50:43
Intro to Java Programming - Course for Absolute Beginners
3:48:25
freeCodeCamp.org
Рет қаралды 3,5 МЛН
AWS Certified Cloud Practitioner Training 2020 - Full Course
3:58:01
freeCodeCamp.org
Рет қаралды 7 МЛН
Codeforces Round 667 (Div. 3) Stream + All Solutions (A-F) (+ extra)
3:55:56