Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up

Find the Second Largest of Four Numbers

Acceptance 89.48% Points 10.00

You are given four integers. Your task is to return the second largest value among them.

Examples
Example 1

image Input: a = 3, b = 9, c = 7, d = 5
Output: 7
Explanation: The largest value is 9, and the second largest value is 7.

Example 2

image Input: a = 10, b = 10, c = 4, d = 2
Output: 10
Explanation: With duplicate largest values, the second largest is also 10.

Example 3

image Input: a = 1, b = 2, c = 3, d = 4
Output: 3
Explanation: After 4, the next largest value is 3.

Constraints
    • -10? = each number = 10?
Companies
Samsung Nutanix
Topics
Array Sorting Algorithms
Solution.cs C#JavaPythonC++Javascript

Unlock the code editor

Sign in to write, run, and submit your solution against the full test suite.

  • Run code against sample & hidden test cases
  • Save submissions and track your streak
  • Compare with editorial & community solutions