Given a string str, consisting of lowercase English alphabets, the task is to calculate the sum of indices(1-based indexing) of the characters removed to obtain an empty string by the following operations:
#arrays #hash #mathematical #recursion #searching #strings #frequency-counting #java-hashmap #segment-tree