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

0% completed

Vote For New Content
why do we need to compare the len(matches) to the len(freq) why not something el...

Daniel Lim

Sep 16, 2022

why do we need to compare the len(matches) to the len(freq) why not something else?

also why do have to do this part: char_frequency[left_char] += 1

0

0

Comments
Comments
D
Douglas 3 years ago

when we advance the left pointer we are removing the char the left pointer was pointing from the window. So we need to update the HashMap to reflect that fact by adding one, meaning "we will need to find one more this char because I've just unseen one of it"

D
Douglas 3 years ago

the len(freq) tell us how many different chars we need to match to find a permutation

On this page