The Percentage of Letter in String problem asks you to find the percentage of occurrences of a given letter in a string (floor division). This easy coding problem tests basic string counting and integer division. The string interview pattern is demonstrated at its simplest.
American Express asks this as a quick programming warmup to verify basic string manipulation skills: counting character occurrences and computing percentages.
Count and compute. Count occurrences of letter in s. Return count * 100 // len(s) (integer floor division for percentage).
s="foobar", letter='o'. Count of 'o'=2. Percentage = 2*100//6 = 200//6 = 33.
s="aaa", letter='a'. Count=3. 3*100//3 = 100.
s="abc", letter='d'. Count=0. 0*100//3 = 0.
Simple counting problems like this test accuracy and speed. The key detail is floor division (//), not rounding. Verify: count * 100 // len(s) gives integer percentage rounded down. For Python users, // naturally floors; for Java/C++ users, integer division floors automatically for positive values. Always double-check the division direction (floor vs ceiling vs round) in percentage problems.