Determine the two Strings Are Close | leetcode 1657

preview_player
Показать описание

1) 0:00 Explaining the problem out loud
2) 1:28 Algorithm walkthrough
3) 7:00 Coding it up
4) 12:00 Time complexity

TC : O(max( l1, l2 ))
SC:O(1)

Рекомендации по теме
Комментарии
Автор

Thank you for this nice detailed explanation. Please keep it up.

omnamahshivaya
Автор

it's failing for the test case: and

sakshamsrivastava
Автор

Is there any way to be guided personally .

ushmitadutta
Автор

hashsets don't allow duplicates, so isn't this solution missing something ?
consider the case that 2 strings has the same chars and has the same frequencies but one of the frequencies is repeated differently in both strings, for example
string1 : aaabbbcc, string2: aaabbcc
so both char sets will be equal and both int(occurrences) sets will be equal (2, 3), (2, 3) but this actually should produce false

abdelrahmankamal
Автор

Hey man, How can be the SC be 1?. you are creating 6 containers (2 arrays, 4 sets) and in the worst case, you will push all the chars in all the containers. How can it be O(1)?. Isn’t something like O(6*N?.

RajatSingh-dgov
join shbcf.ru