image_2022-05-24_13-59-41.png
25.6 KB
#N2278. Percentage of Letter in String
problem link
#solution
problem link
#solution
class Solution {
public int percentageLetter(String s, char letter) {
int count=0;
for(char ch: s.toCharArray())
if(ch==letter) count++;
return count*100/s.length();
}
}