First time I am facing this problem I submitted a wrong code which passed all tc After watching ur video I realized that I did a small wrong for which code should not run And surprisingly now i am trying to submit the old code which was accepted it is showing Rte 😅
if (str[index + 1] == '0' && i - index - 1 > 1) return false; if (str[index + 1] == '0' && str.length() - index - 1 > 1) return false; for checking leading zeros at start and end
i solved on my own, but they changed test cases, did few modifications now , working fine idk why they do this... btw we can use regex to solve these type of problem also.... I will try that later... and ye technically TC bhi O(1) hua an since str length is 15 max....
sahi hai bhai, mera bhi same logic hi tha bs andr int val = Integer.parseInt(arr[i]); if(val255){ return false; } ye inner loop m code tha sare tc pass kr gye
Sir What a Beautiful Explanation
Thanks 🙏❤️
well and informative explain vaiya💖
Thanks a lot 🙏❤️
First time I am facing this problem
I submitted a wrong code which passed all tc
After watching ur video I realized that I did a small wrong for which code should not run
And surprisingly now i am trying to submit the old code which was accepted it is showing Rte 😅
Sometimes GFG changes the test cases.
I also faced the same problems a few times.
@@AMANKUMAR-bt6cw achha
Yes gfg changes the test cases.
Solved on my own, Thank you bhaiyya
Keep it up 🙌
@@code_kar_lo yes thank you bhaiya
if (str[index + 1] == '0' && i - index - 1 > 1) return false;
if (str[index + 1] == '0' && str.length() - index - 1 > 1) return false;
for checking leading zeros at start and end
i solved on my own, but they changed test cases, did few modifications now , working fine
idk why they do this...
btw we can use regex to solve these type of problem also....
I will try that later...
and ye technically TC bhi O(1) hua an since str length is 15 max....
Hn string ki length bohat jyada nhi hogi
public boolean isValid(String str) {
String[] arrOfStr = str.split("\\.");
if(arrOfStr.length != 4){
return false;
}
for(int i=0;i 1) && (arrOfStr[i].charAt(0)) == '0' ){
return false;
}
int x=Integer.parseInt(arrOfStr[i]);
if(x
sahi hai bhai, mera bhi same logic hi tha bs andr
int val = Integer.parseInt(arr[i]);
if(val255){
return false;
}
ye inner loop m code tha sare tc pass kr gye