Why this question is in the deque section?
Also i dont understand the implementation and logic at al…please explain it to me
Please answer this
Hey Anshul,
this question is based on sliding window which is a deque only!
the idea is to maintain a deque, starting from 0 index(of given string), expand the deque by inserting current char. Now if this char already existed inside deque, shrink it by deleting elements from front of deque until this char is deleted.
After every operation, maintain a variable answer which stores max_length of deque.
eg: let the string is “abcdb”
here the deque goes like:
“a”
“ab”
“abc”
“abcd”
“abcdb”–>‘b’ occurs already so remove from front until prev ‘b’ is not removed
“cdb”
Final answer is 4 (“abcd”)