Количество лексикографически меньших символов справа
Опубликовано: 1 Декабря, 2021
Дана строка, состоящая только из строчных букв английского алфавита. Задача состоит в том, чтобы подсчитать общее количество алфавитно меньших символов справа от символов по каждому индексу.
Примеры:
Input: str = “edcba”
Output: 4 3 2 1 0
Explanation:
The number of characters on the right side of index 0 which is smaller than
e are dcba = 4
The number of characters on the right side of index 1 which is smaller than
d are cba = 3
The number of characters on the right side of index 2 which is smaller than
c are ba = 2
The number of characters on the right side of index 3 which is smaller than
b are a = 1
The number of characters on the right side of index 4 which is smaller than
a are ‘