bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot dhynawaad sir always put videos like this only others doesnt include the whole concept behind the thought process and how you came to this solution the video length is long but its not a problem sir please post daily........
Thank you Sir , I was really thinking it from some time that in questions where OR is involved you can't backtrack once operation is performed, now I got the idea to approach those cases. Thank you
After watching your explanation I coded this class Solution { public int minimumSubarrayLength(int[] nums, int k) { List list=new ArrayList(); int n=nums.length; int or=0,i=0,j=0; int bits[]=new int[32]; int ans=Integer.MAX_VALUE; while(j=k) return 1; // to reduce lots of operations // store the bits when it is 1 then store with the index for(int a=0;a>=1; } num=nums[j]; // perform or or|=num; /* check if my or value is greater than k then ->> remove the last first ele 1. to do that we need to minus the bits in bits array 2. recalculate OR(|) with updated bits array */ while(i=k){ num=nums[i]; ans=Math.min(ans,j-i+1); // 1. for removing bits from bits array for(int b=0;b>=1; } // 2. recalculating OR or=0; for(int b=0;b0){ or|=(1
Done bhaiya Such a nice explaination code dimmag me hi ho gaya pura❤🙌🙌 int minimumSubarrayLength(vector& nums, int k) { int n=nums.size(); int mini=n+1; int i=0,j=0; int cur_OR=0; vector bits(32,0); while(j
@shanmukhtejareddy371 that I know,,but this channel solution is more better curated because the solution is given based on the Playlist template....that's the reason why I am asking him for the solutions...by the way thnx for your time
Bhaiya, can you pls make one on Ransom Note, 383.... although i solved it and it was an easy level question, i wish to know if there are any more approaches to the same....
sir me daily aapka video dekh tha hu aur question solve kartha hu magar me khud se brute force tak nikhal tha huu . in fact in some problems vo bhi nikhalna mushkil he me abhi second year me huu btech ka aur mera cgpa bhi uthna aacha nahi heee ab me kya karu ?? bohoth tension hothi heee
Algorithm X Don knuth, I'm requesting you to make a video explaining that algorithm , I'm currently working on a project I need to understand, I'll be highly grateful to you.
Bhaiya ek doubt tha, topics like segment tree, digit DP, bitmask DP, ye sab interview main puchte hai kaya? Main in general sari companies ke liye puch raha hu
i passed 475 / 718 testcases with class Solution { public: int minimumSubarrayLength(vector& nums, int k) { int n = nums.size(); int cumulativeOR = 0; int start = 0; int minLength = INT_MAX; for (int end = 0; end < n; end++) { cumulativeOR |= nums[end];
Hello Bhaiya I have attempted this question but unable to pass 2 test cases my solution was -> class Solution { public int minimumSubarrayLength(int[] nums, int k) { int ans=Integer.MAX_VALUE; int maxOr=0; int left=0; for(int right=0;right=k && left
your solution is correct. It's just that your solution is slow. The last 2 large test cases will give TLE. The bitwise OR (maxOr) is recalculated entirely from left to right in each iteration of the inner while loop, which is inefficient.
// using segment tree TC : O(N log N ) // someOne commented that it can be solved using segment tree & it took 1 hour of my sleeptime. class Solution { public int minimumSubarrayLength(int[] nums, int k) { int n = nums.length; int[] st = new int[n * 4]; buildSegmentTree(0, 0, n - 1, st, nums); int i = 0, j = 0; int ans = Integer.MAX_VALUE; while (j < n) { while (i = k) { ans = Math.min(ans, j - i + 1); i++; } j++; } return ans == Integer.MAX_VALUE ? -1 : ans; } private int getOr(int start, int end, int[] nums, int[] st) { return getInterval(start, end, 0, 0, nums.length - 1, st); } private void buildSegmentTree(int i, int l, int r, int[] st, int[] nums) { if (l == r) { st[i] = nums[l]; return; } int mid = (l + r) >> 1; buildSegmentTree(2 * i + 1, l, mid, st, nums); buildSegmentTree(2 * i + 2, mid + 1, r, st, nums); st[i] = st[2 * i + 1] | st[2 * i + 2]; } private int getInterval(int start, int end, int i, int l, int r, int[] st) { if (l > end || r < start) return 0; if (l >= start && r > 1; int left = getInterval(start, end, 2 * i + 1, l, mid, st); int right = getInterval(start, end, 2 * i + 2, mid + 1, r, st); return left | right; } }
Video aane me deri hoo sakti hai par video aane ki gurrentee pakaki ❤❤ thank u sir
Apologies for the delay today. Was a little occupied in Sunday activities today ❤️
@@codestorywithMIK sir how can do the question too easily
@@soumyajitpaul-p8z practice didi
Solved it using segment tree, but came for sliding window approach
KItna bit manipulation hoga iss maheenee. Puri playslist dekh kr seekh leta hu bohot nayi cheeze h isme.Thanks a lot MIK!
this week has 111 days
Sahi mai sir kya gazab technique se question solve karte ho aap
men u r so great kya intutiton sikhaya hai
hatsoff
Means a lot ♥️♥️🙏🙏
@ 🙇
bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot bhot dhynawaad
sir always put videos like this only others doesnt include the whole concept behind the thought process and how you came to this solution the video length is long but its not a problem sir please post daily........
Got to know how to perform sliding window in bit manipulation, It's amazing. Thank you sir
i love your videos brother, keep making daily question videos :) im sure you will hit big someday.
Thank you Sir , I was really thinking it from some time that in questions where OR is involved you can't backtrack once operation is performed, now I got the idea to approach those cases. Thank you
Was waiting for the whole day, so that I can understand from you.
Thanks. 😍
bhaiya subah se intjar me tha
Thank you so much Bhaiya ji 🙏🙏🙏
Finally, the LEGEND is here.
Was waiting MIK
Radhe Radhe ❤
always waiting for you sir .....❤❤.. no matter how late you are , i know it will be worth the wait.
After watching your explanation I coded this
class Solution {
public int minimumSubarrayLength(int[] nums, int k) {
List list=new ArrayList();
int n=nums.length;
int or=0,i=0,j=0;
int bits[]=new int[32];
int ans=Integer.MAX_VALUE;
while(j=k) return 1; // to reduce lots of operations
// store the bits when it is 1 then store with the index
for(int a=0;a>=1;
}
num=nums[j];
// perform or
or|=num;
/*
check if my or value is greater than k
then ->> remove the last first ele
1. to do that we need to minus the bits in bits array
2. recalculate OR(|) with updated bits array
*/
while(i=k){
num=nums[i];
ans=Math.min(ans,j-i+1);
// 1. for removing bits from bits array
for(int b=0;b>=1;
}
// 2. recalculating OR
or=0;
for(int b=0;b0){
or|=(1
Best explanation ❤❤
ThankYou Very Much MIK Sir ,
I Request You To Launch A Paid Course For DSA , I Will Definitely Purchase it
Can you make a video on leetcode biweekly contest problem maximum frequency of elements after performing operation I and II
गजब पढ़ाते हो सर, मजा ही आ जाता है aap ko sundar si madam mile
Fantastic. Worth the wait.
Marvellous 🤩
Samjh gaya 😊 34:16
Glad to know Sarang ♥️🙏
Bhaiya I think ek dsa series apse a gyi toh paid wla toh jarur darenga
Done bhaiya Such a nice explaination code dimmag me hi ho gaya pura❤🙌🙌
int minimumSubarrayLength(vector& nums, int k) {
int n=nums.size();
int mini=n+1;
int i=0,j=0;
int cur_OR=0;
vector bits(32,0);
while(j
Aaj sachme yr question kaa approach hi dhyan me nahi aa raha tha
Sir please contest bhi solve krne lagiye
Ajj, ka topic smjh nahi aya 😢😢,jabke mera sliding window concept achaa, ha fir bhi ,shayed bit manipulation mai ,revision chahie❤❤❤
Bhaiya pls make video on tomorrow leetcode biweekly as well as today's leetcode weekly contest....it's a humble request...
Follow TLE eliminators for weekly and biweekly contest solns
@shanmukhtejareddy371 that I know,,but this channel solution is more better curated because the solution is given based on the Playlist template....that's the reason why I am asking him for the solutions...by the way thnx for your time
Sure Sourabh.
Let me plan soon to consistently post contests too ♥️🙏
@@codestorywithMIK thnx sir❣️
Bhaiya, can you pls make one on Ransom Note, 383.... although i solved it and it was an easy level question, i wish to know if there are any more approaches to the same....
sir me daily aapka video dekh tha hu aur question solve kartha hu magar me khud se brute force tak nikhal tha huu . in fact in some problems vo bhi nikhalna mushkil he
me abhi second year me huu btech ka aur mera cgpa bhi uthna aacha nahi heee ab me kya karu ?? bohoth tension hothi heee
Algorithm X Don knuth, I'm requesting you to make a video explaining that algorithm , I'm currently working on a project I need to understand, I'll be highly grateful to you.
+1
hello sir are there some problems based on frequency for each bit on leetcode, so that we can practice
Any more questions where we can use this bit manipluation apporach to solve problems? 22:16 @codestorywithMIK
Ist view as always ❤
intuition, approach ap jo jo bole wo sab aa gaya tha par OR operation mein kyese minus hoga ye nehi pata tha, to solve nehi ho paya
Bhaiya ek doubt tha, topics like segment tree, digit DP, bitmask DP, ye sab interview main puchte hai kaya? Main in general sari companies ke liye puch raha hu
🔥🔥🔥🔥
i have no laptop. I submitted Solution from my mobile. can i learn html and css from my mobile?
❤❤❤❤
sir if possible
biweekly ka b aur c please
bhaiya please upload a video solution of leetcode weekly contest bhaiya
i passed 475 / 718 testcases with
class Solution {
public:
int minimumSubarrayLength(vector& nums, int k) {
int n = nums.size();
int cumulativeOR = 0;
int start = 0;
int minLength = INT_MAX;
for (int end = 0; end < n; end++) {
cumulativeOR |= nums[end];
while (cumulativeOR >= k && start
why this not working
First 🎉❤
bro itni jaldi kaise ?
Apologies for the delay today. Was a little occupied in Sunday activities today ❤️
🔥++
besttttttttttttttttttttttttttttttt
Hello Bhaiya I have attempted this question but unable to pass 2 test cases my solution was ->
class Solution {
public int minimumSubarrayLength(int[] nums, int k) {
int ans=Integer.MAX_VALUE;
int maxOr=0;
int left=0;
for(int right=0;right=k && left
your solution is correct. It's just that your solution is slow. The last 2 large test cases will give TLE.
The bitwise OR (maxOr) is recalculated entirely from left to right in each iteration of the inner while loop, which is inefficient.
public int minimumSubarrayLength(int[]nums,int k){
int n=nums.length,l=0,r=0,len=n+1,or=0;
int[]bits=new int[32];
if(k==0) return 1;
while(r=k){
len=Math.min(len,r-l+1);
or=remove(bits,nums[l]);
l++;
}
r++;
}
return len==n+1?-1:len;
}
private int remove(int[]arr,int n){
int i=0;
while(n>0){
if((n&1)==1){
arr[i]--;
}
n>>=1;
i++;
}
int decimal=0;
i=0;
for(;i0)
decimal+=Math.pow(2,i);
}
return decimal;
}
private void add(int[]arr,int n){
int i=0;
while(n>0){
if((n&1)==1){
arr[i]++;
}
n>>=1;
i++;
}
}
leetcode Codec biweekly contest problem 2and 3 is same slidingWindow patterns
Why your ipad battery is always low while recording the video
// using segment tree TC : O(N log N )
// someOne commented that it can be solved using segment tree & it took 1 hour of my sleeptime.
class Solution {
public int minimumSubarrayLength(int[] nums, int k) {
int n = nums.length;
int[] st = new int[n * 4];
buildSegmentTree(0, 0, n - 1, st, nums);
int i = 0, j = 0;
int ans = Integer.MAX_VALUE;
while (j < n) {
while (i = k) {
ans = Math.min(ans, j - i + 1);
i++;
}
j++;
}
return ans == Integer.MAX_VALUE ? -1 : ans;
}
private int getOr(int start, int end, int[] nums, int[] st) {
return getInterval(start, end, 0, 0, nums.length - 1, st);
}
private void buildSegmentTree(int i, int l, int r, int[] st, int[] nums) {
if (l == r) {
st[i] = nums[l];
return;
}
int mid = (l + r) >> 1;
buildSegmentTree(2 * i + 1, l, mid, st, nums);
buildSegmentTree(2 * i + 2, mid + 1, r, st, nums);
st[i] = st[2 * i + 1] | st[2 * i + 2];
}
private int getInterval(int start, int end, int i, int l, int r, int[] st) {
if (l > end || r < start) return 0;
if (l >= start && r > 1;
int left = getInterval(start, end, 2 * i + 1, l, mid, st);
int right = getInterval(start, end, 2 * i + 2, mid + 1, r, st);
return left | right;
}
}
Thailand m ky krre ho😅
❤❤