Error
|
|
---|---|
@Ibrahim Nash | 5761 |
@blackshadows | 5715 |
@akhayrutdinov | 5111 |
@mb1973 | 4989 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 1115 |
@bt8816103042 | 739 |
@SherlockHolmes3 | 447 |
@codeantik | 441 |
@SHOAIBVIJAPURE | 430 |
@shalinibhataniya1097 | 408 |
@ShamaKhan1 | 392 |
@neverevergiveup | 381 |
@amrutakashikar2 | 355 |
@mahlawatep | 353 |
@murarry3625 | 352 |
Complete Leaderboard |
Given a string S. Count the characters that have ‘N’ number of occurrences. If a character appears consecutively it is counted as 1 occurrence.
Example 1:
Input:
S = "abc", N = 1
Output: 3
Explanation: 'a', 'b' and 'c' all have
1 occurrence.
​Example 2:
Input:
S = "geeksforgeeks", N = 2
Output: 4
Explanation: 'g', 'e', 'k' and 's' have
2 occurrences.
Your Task:
You don't need to read input or print anything. Your task is to complete the function getCount() which takes the string S and an integer N as inputs and returns the count of the characters that have exactly N occurrences in the string. Note that the consecutive occurrences of a character have to be counted as 1.
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1).
Constraints:
1<=|S|<=105
1<=N<=103
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes