Sorry bro but I disagree with all your statements.
- r-l < 2 is correct because it’s inclusive. So if l = 2 and r = 4, it should pass as S[2]…S[4] is a valid substring of length 3.
- It doesn’t access out of bound and all elements are covered in this loop too.
- It runs in time, but gets a WA. Complexity is not the issue here I guess, it’s the logic.
shim98
23
it should be r-l+1
// 20 char
shim98
25
Finally you will be 4 stars then? XD
Dammmn some people be carrying sick templates
1 Like
Kabhi bhi kuch bhi kaam aajataa hai…
1 Like
Yes first point is wrong. Sorry for that.
Second one is misleading too. I should sleep now xD I meant you can miss last two index check for this loop.
Third applies when WA will not come. Consider a string like abcdef…xyzabcd…xyzaa and every query from 1 to 10^5
1 Like