Тёмный

Valid Anagram - LeetCode 242 - Python 

Gordon Zhu
Подписаться 6 тыс.
Просмотров 427
50% 1

Опубликовано:

 

25 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 4   
@jhawar-ji
@jhawar-ji 3 месяца назад
what about this code ? ... ts= Counter(t) ss= Counter(s) if ts!=ss: return False return True
@GordonZhu
@GordonZhu 3 месяца назад
I alluded to approaches like this at 6:00 (and why I avoided them). That said, I don't think the variable names "ts" and "ss" add any clarity, and your boolean logic can be simplified. So if you were intent on comparing Counter instances using ==, I'd do it like this: return Counter(s) == Counter(t)
@jhawar-ji
@jhawar-ji 3 месяца назад
@@GordonZhu I just wrote this without any second thoughts so didn’t put attention to the variables. But yeah direct comparison also makes sense
@GordonZhu
@GordonZhu 3 месяца назад
All good. Thanks for sharing!
Далее
Ransom Note - LeetCode 383 - Python
9:15
Просмотров 244
Two Sum | LeetCode 1 | JavaScript | Easy
13:20
Просмотров 10 тыс.
Свожу все свои тату (abricoss_a_tyt)
00:35
Two Sum - LeetCode 1 - Python
13:15
Просмотров 1,2 тыс.
Contains Duplicate - LeetCode 217 - Python
9:53