Lesson 17 of 23

String Problems: Reverse, Palindrome, Frequency

11 min 30 XP

Interviews ask you to write string code without library helpers like strrev. Two tricks cover most questions: swapping from both ends (two pointers) and a count array of size 26.

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

Challenge

+30 XP

Read a lowercase word with scanf("%s") and print the most frequent letter and its count. On a tie, print the alphabetically first letter. Input: banana → Output: a 3

Output Loading C (first time takes a few seconds)
Press Run to see the result here.