Given an array of integers, find the second largest distinct element. Return -1 if it doesn't exist.
Input: nums = [12, 35, 1, 10, 34, 1] Output: 34
Input: nums = [10, 5, 10] Output: 5
Input: nums = [7, 7, 7] Output: -1
Jnaneshwara Reddy Satti
Builder · ClearCode
Hi — I'm a 21yo CS grad from India. I built ClearCode while recovering from a surgery, because I genuinely believe DSA should be visual, free, and accessible to everyone. No VC funding. No team. Just me, my laptop, and a lot of chai. ☕
If ClearCode helped you understand even one concept — consider supporting it. Every rupee keeps the servers running and new videos coming.