Java · DSA · Arrays ◐ Find the second largest distinct element in an array in a single pass , with no sorting and no extra array. Watch largest and secondLargest update step by step on your own input. 01 Problem 02 Code 03 How it works 04 Tracer 05 Approaches 06 Revision 07 Quiz 01 The problem Given an array of N integers, print the second largest distinct value. Duplicates of the largest don't count. If there is no second distinct value, print -1 . For [10, 20, 20, 15, 5] , the largest is 20. The next distinct value below it is 15 . For [7, 7, 7] there is no second value, so the answer is -1 . Type an array to see what the program prints. Negative numbers work too. Array (spaces or commas) Run 02 The code Keep two variables while walking the array once: largest and secondLargest . A boolean, isSLargestFound , records whether a r...
Keen to design and develop web apps by leveraging various java based technologies and tools like springboot,microservices,docker,kubernetes,spring security,thymeleaf,jakarta,spring cloud, java 8.