Variable size Sliding window | DSA in java Part 37

Поделиться
HTML-код
  • Опубликовано: 17 ноя 2024

Комментарии • 18

  • @bharathaileni6400
    @bharathaileni6400 Месяц назад +1

    class Solution {
    public int totalFruit(int[] fruits) {
    int n=fruits.length,l=0,ans=0;
    HashMap hm=new HashMap();
    for(int i=0;i2)
    {
    hm.put(fruits[l],hm.get(fruits[l])-1);
    if(hm.get(fruits[l])==0)
    {
    hm.remove(fruits[l]);
    }
    l++;
    }
    ans=Math.max(ans,i-l+1);
    }
    return ans;
    }
    }

  • @WORK-HARD-jm4cg
    @WORK-HARD-jm4cg Месяц назад

    class Solution:
    def totalFruit(self, s: List[int]) -> int:
    dic={}
    l=0
    ans=0
    for r in range(len(s)):
    if s[r] not in dic:
    dic[s[r]]=1
    else:
    dic[s[r]]=dic[s[r]]+1
    while len(dic)>2:
    dic[s[l]]=dic[s[l]]-1
    if dic[s[l]]==0:
    del dic[s[l]]
    l=l+1
    ans=max(ans,r-l+1)
    return ans

  • @lavan1119
    @lavan1119 Месяц назад

    class Solution {
    public int totalFruit(int[] fruits) {
    int temp=0;
    int l=0;
    int ans=0;
    HashMap hash = new HashMap();
    for(int i=0;i2){
    temp=fruits[l];
    hash.put(temp,hash.get(temp)-1);
    if(hash.get(temp)==0){
    hash.remove(fruits[l]);}
    l++;
    }
    ans=Math.max(ans,i-l+1);
    }
    return ans;

    }
    }

  • @SaiKarthik-rj5hy
    @SaiKarthik-rj5hy Месяц назад

    Same logic naku vachindhi kani code rayadam kastam ga undi bro

  • @Mahesh-pu5gm
    @Mahesh-pu5gm Месяц назад

    Broo linkedList pinna oka video cheyadhi plzz mids unnaayi 14th ki exam aa video chusina artham aytha leee so meru kocham help cheyadhi

  • @janekrish7547
    @janekrish7547 Месяц назад

    I created 3 localhost servers into public through ngrok in those 2 url from backed and one was frontend the 2 url's from the backend fetched into the frontend by ngrok url's but those those public url's from backend not working in the frontend can you say the reason bro? but the urls from the backend after creating into public working properly in saperate browser but not after fetching by the frontend, again the problem is not even by the cors can you say the reason bro?

  • @exploring_my_world
    @exploring_my_world Месяц назад

    Dont stop mowa ...keep going on,🫴❣️

  • @unknownuser-h9r
    @unknownuser-h9r Месяц назад +1

    bruh today class?

  • @MrChotu-xy1xz
    @MrChotu-xy1xz Месяц назад

    Dsa Ani months paduthumdhi bro complete ga

  • @GaneshGanesh-f6w6p
    @GaneshGanesh-f6w6p Месяц назад +1

    Hi Anna DSA with c++ chpuu

    • @SaiKarthik-rj5hy
      @SaiKarthik-rj5hy Месяц назад

      Ippatikeh java and python tho manage cheydaniki kasta paduthunadu bro max kastam C++ kuda antey

    • @SaiKarthik-rj5hy
      @SaiKarthik-rj5hy Месяц назад

      kavalitey TakeYouForward( striver) channel lo chudu bro c++ tho chepadu

  • @suryasai7135
    @suryasai7135 Месяц назад

    Bro don't do all the problems. Explain the concept and solve few problems. Rest give as assignment

  • @jaswanthandhavarapu4325
    @jaswanthandhavarapu4325 Месяц назад

    class Solution {
    public int totalFruit(int[] fruits) {
    int l = 0;
    HashMap map = new HashMap();
    int max = 0;

    for(int r = 0; r2){
    if(map.get(fruits[l])>1) map.put(fruits[l],map.get(fruits[l])-1);
    else map.remove(fruits[l]);
    l++;
    }
    for(int i :map.values()) {
    count += i;
    }
    max = Math.max(max,count);
    }
    return max;
    }
    }
    time taken 44 mins because weak concepts of maps (runtime - 91ms)
    extra time taken 24 mins

  • @Chintapakdamdam-e3d
    @Chintapakdamdam-e3d Месяц назад

    public int totalFruit(int[] fruits) {
    HashMaphm=new HashMap();
    int len=fruits.length;
    int ans=0;
    int l=0;
    for(int r=0;r2){
    int val1=hm.get(fruits[l]);
    hm.put(fruits[l],val1-1);
    if(hm.get(fruits[l])==0){
    hm.remove(fruits[l]);
    }
    l++;
    }
    ans=Math.max(ans,r-l+1);
    }
    return ans;
    }
    }
    bro starting konchem tough emo give up iddham anukunna but inkosari try chesa....took 40min but finally got it kani konchem help tesukunna from chatgpt
    tqq so much bro

  • @thop4505
    @thop4505 Месяц назад

    macha prathi sari oka hint evvu

  • @pavankarthik9488
    @pavankarthik9488 Месяц назад

    Vere topic start chedham Vignesh !!!!