Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up

Find the Second Smallest of Four Numbers

Acceptance 89.85% Points 10.00

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

Examples
Example 1

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

Example 2

image Input: a = 2, b = 2, c = 8, d = 6
Output: 2
Explanation: With duplicate smallest values, the second smallest is also 2.

Example 3

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

Constraints
    • -10? = each number = 10?
Companies
Infosys Cognizant
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