Write a function:class Solution { public int solution(String s); }that, given a string S consisting of N lowercase letters, returnsthe minimum number of letters that must be deleted to obtaina word in which every letter occurs a unique number of times.We only care about occurrences of letters that appear at leastonce in result.Examples:1. Given S = 'aaaabbbb", the function should return 1. We candelete one occurrence of a or one occurrence of b. Then oneletter will occur four times and the other on the
Answers
Answer:
Explanation:
Given string str, the task is to find the minimum count of characters that ... to make frequency of each character unique by minimum number of ... try your approach on {IDE} first, before moving on to the solution. ... int N). {. // Stores frequency of each. // distinct character of str ... required to be deleted to make
Answer:
Write a function:class Solution { public int solution(String s); }that, given a string S consisting of N lowercase letters, returnsthe minimum number of letters that must be deleted to obtaina word in which every letter occurs a unique number of times.We only care about occurrences of letters that appear at leastonce in result.Examples:1. Given S = 'aaaabbbb", the function should return 1. We candelete one occurrence of a or one occurrence of b. Then oneletter will occur four times and the other on the