Shortest Subarray With OR at Least K II | Made Easy | Detailed | Leetcode 3097 | codestorywithMIK

Поділитися
Вставка
  • Опубліковано 20 гру 2024

КОМЕНТАРІ • 69

  • @sarangkale6761
    @sarangkale6761 Місяць тому +43

    Video aane me deri hoo sakti hai par video aane ki gurrentee pakaki ❤❤ thank u sir

    • @codestorywithMIK
      @codestorywithMIK  Місяць тому +18

      Apologies for the delay today. Was a little occupied in Sunday activities today ❤️

    • @soumyajitpaul-p8z
      @soumyajitpaul-p8z Місяць тому +2

      @@codestorywithMIK sir how can do the question too easily

    • @rajshiromani727
      @rajshiromani727 Місяць тому +1

      ​@@soumyajitpaul-p8z practice didi

  • @mazinshamshad3838
    @mazinshamshad3838 Місяць тому +12

    Solved it using segment tree, but came for sliding window approach

  • @Divyansh-n3h
    @Divyansh-n3h Місяць тому +2

    KItna bit manipulation hoga iss maheenee. Puri playslist dekh kr seekh leta hu bohot nayi cheeze h isme.Thanks a lot MIK!

  • @rakshitdevra7060
    @rakshitdevra7060 Місяць тому +1

    Sahi mai sir kya gazab technique se question solve karte ho aap

  • @jain5184
    @jain5184 Місяць тому +5

    men u r so great kya intutiton sikhaya hai
    hatsoff

  • @dopeee1
    @dopeee1 Місяць тому +1

    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........

  • @SaurabhSinghyadav-r4y
    @SaurabhSinghyadav-r4y Місяць тому +1

    Got to know how to perform sliding window in bit manipulation, It's amazing. Thank you sir

  • @moonlikedi7u314
    @moonlikedi7u314 Місяць тому +1

    i love your videos brother, keep making daily question videos :) im sure you will hit big someday.

  • @Rohit_Gunwal
    @Rohit_Gunwal Місяць тому +1

    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

  • @indiann871
    @indiann871 Місяць тому +1

    Was waiting for the whole day, so that I can understand from you.
    Thanks. 😍

  • @mayank.malviyaa
    @mayank.malviyaa Місяць тому +1

    bhaiya subah se intjar me tha

  • @rockykumarverma980
    @rockykumarverma980 Місяць тому

    Thank you so much Bhaiya ji 🙏🙏🙏

  • @gui-codes
    @gui-codes Місяць тому +1

    Finally, the LEGEND is here.
    Was waiting MIK

  • @amanpaliwalvlogs6860
    @amanpaliwalvlogs6860 Місяць тому +1

    Radhe Radhe ❤

  • @HarmanSingh-nw6ix
    @HarmanSingh-nw6ix Місяць тому +2

    always waiting for you sir .....❤❤.. no matter how late you are , i know it will be worth the wait.

  • @crazychess553
    @crazychess553 Місяць тому +1

    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

  • @Akashkumar_12
    @Akashkumar_12 Місяць тому

    Best explanation ❤❤

  • @MathBytes1008
    @MathBytes1008 Місяць тому +1

    ThankYou Very Much MIK Sir ,
    I Request You To Launch A Paid Course For DSA , I Will Definitely Purchase it

  • @Himanshhhhxu
    @Himanshhhhxu Місяць тому +3

    Can you make a video on leetcode biweekly contest problem maximum frequency of elements after performing operation I and II

  • @Arya20012
    @Arya20012 Місяць тому +2

    गजब पढ़ाते हो सर, मजा ही आ जाता है aap ko sundar si madam mile

  • @thefinalfit
    @thefinalfit Місяць тому

    Fantastic. Worth the wait.

  • @aws_handles
    @aws_handles Місяць тому

    Marvellous 🤩

  • @sarangkale6761
    @sarangkale6761 Місяць тому +1

    Samjh gaya 😊 34:16

  • @sulabhsamrat5129
    @sulabhsamrat5129 Місяць тому +2

    Bhaiya I think ek dsa series apse a gyi toh paid wla toh jarur darenga

  • @jeehub041
    @jeehub041 Місяць тому +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

  • @sarangkale6761
    @sarangkale6761 Місяць тому +2

    Aaj sachme yr question kaa approach hi dhyan me nahi aa raha tha

  • @rajshiromani727
    @rajshiromani727 Місяць тому

    Sir please contest bhi solve krne lagiye

  • @mdshujaullah7072
    @mdshujaullah7072 Місяць тому

    Ajj, ka topic smjh nahi aya 😢😢,jabke mera sliding window concept achaa, ha fir bhi ,shayed bit manipulation mai ,revision chahie❤❤❤

  • @sourabhsinghbhadouriya9711
    @sourabhsinghbhadouriya9711 Місяць тому +3

    Bhaiya pls make video on tomorrow leetcode biweekly as well as today's leetcode weekly contest....it's a humble request...

    • @shanmukhtejareddy371
      @shanmukhtejareddy371 Місяць тому

      Follow TLE eliminators for weekly and biweekly contest solns

    • @sourabhsinghbhadouriya9711
      @sourabhsinghbhadouriya9711 Місяць тому +3

      @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

    • @codestorywithMIK
      @codestorywithMIK  Місяць тому +1

      Sure Sourabh.
      Let me plan soon to consistently post contests too ♥️🙏

    • @sourabhsinghbhadouriya9711
      @sourabhsinghbhadouriya9711 Місяць тому +1

      @@codestorywithMIK thnx sir❣️

  • @chetnarai407
    @chetnarai407 Місяць тому

    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....

  • @NUKALAAKSHITHKUMAR
    @NUKALAAKSHITHKUMAR Місяць тому +2

    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

  • @aayushguptamnit6307
    @aayushguptamnit6307 Місяць тому

    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.

  • @SahilKumar-rw3sh
    @SahilKumar-rw3sh Місяць тому

    hello sir are there some problems based on frequency for each bit on leetcode, so that we can practice

  • @anshnarula7417
    @anshnarula7417 Місяць тому

    Any more questions where we can use this bit manipluation apporach to solve problems? 22:16 @codestorywithMIK

  • @jeehub041
    @jeehub041 Місяць тому +1

    Ist view as always ❤

  • @RishabhChatterjee-fg2gz
    @RishabhChatterjee-fg2gz Місяць тому

    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

  • @arnabsarkar5245
    @arnabsarkar5245 Місяць тому

    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

  • @arnavmohan9820
    @arnavmohan9820 Місяць тому

    🔥🔥🔥🔥

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 Місяць тому +1

    i have no laptop. I submitted Solution from my mobile. can i learn html and css from my mobile?

  • @codeandtalk6
    @codeandtalk6 Місяць тому +1

    ❤❤❤❤

  • @jeevan-23
    @jeevan-23 Місяць тому

    sir if possible
    biweekly ka b aur c please

  • @amankunwar8621
    @amankunwar8621 Місяць тому

    bhaiya please upload a video solution of leetcode weekly contest bhaiya

  • @amolshinde8607
    @amolshinde8607 Місяць тому +1

    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

    • @rooker5954
      @rooker5954 Місяць тому

      why this not working

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 Місяць тому

    First 🎉❤

    • @gui-codes
      @gui-codes Місяць тому

      bro itni jaldi kaise ?

    • @codestorywithMIK
      @codestorywithMIK  Місяць тому +2

      Apologies for the delay today. Was a little occupied in Sunday activities today ❤️

  • @AmarjeetKumar-to9ub
    @AmarjeetKumar-to9ub Місяць тому +2

    🔥++

  • @sayantanpoddar5428
    @sayantanpoddar5428 Місяць тому +1

    besttttttttttttttttttttttttttttttt

  • @ayushmanbaghel7659
    @ayushmanbaghel7659 Місяць тому +1

    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

    • @gui-codes
      @gui-codes Місяць тому +1

      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.

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 Місяць тому +1

    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

  • @LochanSaroy
    @LochanSaroy Місяць тому

    Why your ipad battery is always low while recording the video

  • @deepanshuverma6237
    @deepanshuverma6237 Місяць тому

    // 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;
    }
    }

  • @Engineering.Wallah
    @Engineering.Wallah Місяць тому

    Thailand m ky krre ho😅

  • @beenasatyendrapal6405
    @beenasatyendrapal6405 Місяць тому +1

    ❤❤