Nov-11-2019, 02:13 PM
Hi,
I have to delete minimum number of character in a string.
I saw that there is Counter but I don't know how to use it.
This is my code for now:
RavCoder
I have to delete minimum number of character in a string.
I saw that there is Counter but I don't know how to use it.
This is my code for now:
word = "abecedario alpaca" char = '' word_list = [] #add a string into a list for c in word: word_list.append(c) #print(word_list) #a counter that check if inside a list there is a char count = 0 for counter in word_list: #for any elements of list --> is there char? if counter == char: count = count + 1 #counter print(count)This is text :
Quote:Given a string s consisting of n lowercase letters, you have to delete the minimum number of characters from s so that every letter in s appears a unique number of times. We only care about the occurrences of letters that appear at least once in result.Regards,
RavCoder