A data compression software utilizes various steps to compress a string of data. One of the steps involves finding the count of characters that are not repeated in the string. Write an algorithm for the software developer to find the count of characters that are not repeated in the string.
1
Expert's answer
2021-10-05T18:15:33-0400
def not_repeated_chars_count(our_string):
my_dict = {}
for ch in our_string:
my_dict[ch] = my_dict.setdefault(ch, 0) + 1
my_list = [x for x in my_dict if my_dict[x] == 1]
return len(my_list)
Comments
Leave a comment