Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up

Find the Middle Value Among Three Distinct Numbers

Acceptance 84.12% Points 10.00

You are given three distinct integers. Your task is to return the value that is neither the largest nor the smallest.

Examples
Example 1

image Input: a = 3, b = 9, c = 5
Output: 5
Explanation: 5 lies between 3 and 9.

Example 2

image Input: a = 10, b = 2, c = 6
Output: 6
Explanation: 6 is the median of the three values.

Example 3

image Input: a = 1, b = 3, c = 2
Output: 2
Explanation: 2 is the middle value.

Constraints
    • -10? = each number = 10?
    • All three numbers are distinct.
Companies
Google Media.net
Topics
Comparisons
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