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

Programming Exercises

Create a program to count the frequency of words in a given string.

Medium

Problem Statement

Create a program to count the frequency of words in a given string.

Sample Input

A hardcoded string: "this is a test this is only a test"

Sample Output

Word frequencies: {this=2, is=2, a=2, test=2, only=1}

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun main() { val text = "this is a test this is only a test" // Add your code here to count word frequencies }
Log in or sign up to run or submit your code.Log inSign up
Input
A hardcoded string: "this is a test this is only a test"
Expected Output
Word frequencies: {this=2, is=2, a=2, test=2, only=1}