FastPrepSecond Distinct Largest Element
Problems/Second Distinct Largest Element

Second Distinct Largest Element

HSBC logoHSBC● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamples

Problem statement

Source note: Reported in a HSBC new grad onsite interview. The report names a well-known task. We chose the function signature, a fixed rule for the output, and the limits. Our version is about 98% the same as the reported question.

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[]) → int

Examples

Example 1

nums = [5,1,5,3]return = 3

Example 2

nums = [2,2,1]return = 1

Source note: Author-written prompt excerpt retained for source fidelity.

More HSBC interview questions

  • Maximum 69 NumberONSITE INTERVIEW · Seen Oct 2026
  • Organization Reputation After Employee DeparturesOA · Seen Nov 2026
  • Remove Vowels from a StringOA · Seen Nov 2026
  • Minimum Deletion Cost for Distinct Adjacent CharactersOA · Seen Oct 2026
  • Distinct Products After Removing One ElementOA · Seen Sep 2026
  • Minimum Cleaning Robot RunsOA · Seen Sep 2026
  • Minimum Satellite Data Transfer IterationsOA · Seen Aug 2026
  • Find ID of SoldierOA · Seen Jun 2026
  • Find Most Frequently Purchased ProductsOA · Seen Jun 2026
  • Minimum Markers to Clear Line SegmentsOA · Seen Nov 2025

Similar questions at other companies

  • Bad Request AlertsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Confusing Bib NumbersVerily · ONSITE INTERVIEW
  • Group Transactions by HourAffirm · ONSITE INTERVIEWAffirm interview questions
  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Rotate a Matrix by 90 DegreesIDFC Bank · ONSITE INTERVIEWIDFC Bank interview questions
  • Plus OneDruva · ONSITE INTERVIEW
  • Ring Buffer OperationsAmazon · ONSITE INTERVIEW
  • Rotate a Flat Image ClockwiseGoogle · ONSITE INTERVIEWGoogle interview questions
  • Merge Sorted ArrayDP World · ONSITE INTERVIEW
  • List the Key and Value of Every Map EntryNewgen Software · ONSITE INTERVIEW
All HSBC interview questionsSee HSBC hiring insights
Saved
class Solution {
    public int secondLargestDistinct(int[] nums) {
      // write your code here
    }
}
Checking account…