Back to course home
0% completed
Vote For New Content
Why is matched compared to the number of keys in the charFrequency instead of th...
Dee
Feb 9, 2022
Why is matched compared to the number of keys in the charFrequency instead of the length of the pattern? Can the pattern not have repeating characters such as “ aabc” vs just “abc”?
0
0
Comments
Comments
D
Dee 4 years ago
I reread the instructions and now realize that the pattern cannot have repeating characters. So it should be fine to use the length of pattern or the number of keys in charFreq right?
Design Gurus4 years ago
The pattern can have repeating characters. The algorithm should work for repeating characters.
Why 'matched' is compared to 'charFrequency'? Because 'matched' is incremented only when we have found all occurrences of a character. This algorithm is quite similar to find...
On this page