Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Count the occurrences of a character in a string

Easy

Problem Statement

Count the occurrences of a character in a string

Sample Input

"hello world" and 'l'

Sample Output

The character 'l' occurs 3 times

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun main() { val input = "hello world" val charToCount = 'l' // Add your code here to count the occurrences of the character }
Log in or sign up to run or submit your code.Log inSign up
Input
"hello world" and 'l'
Expected Output
The character 'l' occurs 3 times