Back to course home
0% completed
Vote For New Content
Why we use maxLength?
Abdullah AlKheshen
Jun 15, 2023
// What's the goal or the reason behind using:
maxLength = max(maxLength, windowEnd - windowStart + 1); return maxLength;
while we can simply return j-i?
0
0
Comments
Comments
A
Alfonso Vieyra2 years ago
Why would j - i yield the correct solution? We use a while loop to increment the left pointer which corresponds to decreasing the size of the window. Thus, there are cases where j - i simply would not give us the right result. For example, consider the following test ca...
On this page