Maximum Length Unique Character Substring | Sliding Window

can you explain this in detail?
i-current_len>last_occ

Hello @kunalsaini8950,

  1. The visited array is used to store the index of the character(0 to 255) at which it occurred last time in the string.
    If the character is encountered for the first time, then it would contain -1 as the entire array is initialised to -1.
    This value will be stored in the last_occ variable.

  2. Now, consider the following:
    last_occ: it stores the index at which the current character (i.e. a[i]) occurred before.
    i: current index
    current_length: contains the length of the window

  3. So,
    i-current_length: starting index of the window
    Hence,
    i-current_len>last_occ:
    True: if the index at which the current element occurred present outside the window
    False: if it is present inside the variable.

    It is done to make sure that the current element didn’t occur inside the window before.

Hope, this would help.
Give a like if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.