Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Can someone clarify this line: maxLength = Math.max(maxLength, windowEnd ...

Godspeed

Sep 29, 2022

Can someone clarify this line:

maxLength = Math.max(maxLength, windowEnd - windowStart + 1);

I don't understand what is going on here.

0

0

Comments
Comments
M
Mohammad Khan3 years ago

The Math.max is choosing between two values and picking the highest value. maxlength is your current highest value and windowEnd-windowStart+1 is the new length of the new substring.

On this page