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

Programming Exercises

Write a Kotlin program to find the second largest element in an array.

Medium

Problem Statement

Write a Kotlin program to find the second largest element in an array.

Sample Input

A hardcoded array: [10, 20, 30, 40, 50]

Sample Output

The second largest element is: 40

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun main() { val numbers = arrayOf(10, 20, 30, 40, 50) // Add your code here to find the second largest element }
Log in or sign up to run or submit your code.Log inSign up
Input
A hardcoded array: [10, 20, 30, 40, 50]
Expected Output
The second largest element is: 40