Implement a function to reverse the digits of an integer without converting it to a string.
HardProblem 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)}")
}
Input
A hardcoded integer, e.g., 12345.
Expected Output
Reversed integer: 54321