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

Programming Exercises

Implement a function to reverse the digits of an integer without converting it to a string.

Hard

Problem Statement

Implement a function to reverse the digits of an integer without converting it to a string.

Sample Input

A hardcoded integer, e.g., 12345.

Sample Output

Reversed integer: 54321

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun reverseInteger(num: Int): Int { // Add your code here to reverse the digits } fun main() { val num = 12345 println("Reversed integer: ${reverseInteger(num)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
A hardcoded integer, e.g., 12345.
Expected Output
Reversed integer: 54321