Leetcode - Custom Sort String (Python)

preview_player
Показать описание
July 2021 Leetcode Challenge
Leetcode - Custom Sort String #791
Difficulty: Medium
Рекомендации по теме
Комментарии
Автор

Create a lookup with indices as values and char as key for order string. Then iterate through the string and use bucket sort. This would solve it in linear time.

CEOofTheHood
Автор

The reason why we didn't get an error from the 'd' letter was simply because you were using the collections.defaultdict(int) -> 'd' : 0
So you're all good

edwardteach
Автор

I guess the non ordered characters were being transformed into unicode code point values? That's strange because from what I understand, the letter 'd' is equal to 100

stephan