Second Distinct Largest Element
Updated
Problem statement
Given an integer array nums containing at least two distinct values, return its second-largest distinct value.
Repeated occurrences of the largest value do not count as a separate value.
Function
secondLargestDistinct(nums: int[]) → intExamples
Example 1
nums = [5,1,5,3]return = 3Example 2
nums = [2,2,1]return = 1More MulticoreWare Online Assessment questions
Similar questions at other companies
- Missing IntervalsIBM · OAIBM interview questions
- Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Count Valid Square PairsAuxoAI · OA
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Two SumAmazon · OA · PHONE SCREEN
- Competition Winner and Runner-Up (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Server InvestmentRippling · OARippling interview questions
- Book Reading EveningsGoogle · OAGoogle interview questions