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
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;
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?
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
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
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;
}
}
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
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;
}
}
Same logic naku vachindhi kani code rayadam kastam ga undi bro
Broo linkedList pinna oka video cheyadhi plzz mids unnaayi 14th ki exam aa video chusina artham aytha leee so meru kocham help cheyadhi
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?
Dont stop mowa ...keep going on,🫴❣️
bruh today class?
Dsa Ani months paduthumdhi bro complete ga
Hi Anna DSA with c++ chpuu
Ippatikeh java and python tho manage cheydaniki kasta paduthunadu bro max kastam C++ kuda antey
kavalitey TakeYouForward( striver) channel lo chudu bro c++ tho chepadu
Bro don't do all the problems. Explain the concept and solve few problems. Rest give as assignment
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
and also doubt is that should maintain a running notes?
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
macha prathi sari oka hint evvu
Vere topic start chedham Vignesh !!!!