As reported: SAP Labs Developer Associate (Java full stack, 2025), technical round 2 (45 minutes): two coding problems written in Java pseudocode, then resume questions. Problem 1: the second largest element in an array (the GeeksforGeeks problem).
Given an array arr of positive integers, return the second largest element. The second largest must be strictly smaller than the largest. If it does not exist, return -1.
Example 1
arr = [12,35,1,10,34,1] -> 34
Example 2
arr = [10,5,10] -> 5
Example 3
arr = [10,10,10] -> -1
Constraints: 2 ≤ n ≤ 10^5; 1 ≤ arr[i] ≤ 10^5.
Code runner format: one JSON value per line: arr. Implement getSecondLargest(arr); the harness prints the value.