JuniorString

Percentage of Letter in String

Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent.

Example 1
Inputs = "foobar", letter = "o"
Output33
The percentage of characters in s that equal the letter o is 2 / 6 * 100% = 33% when rounded down, so we return 33.
Example 2
Inputs = "jjjj", letter = "k"
Output0
The percentage of characters in s that equal the letter k is 0%, so we return 0.

Constraints

  • 1 <= s.length <= 100
  • s consists of lowercase English letters.
  • letter is a lowercase English letter.

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate