Second Maximum of Three Numbers
EasyP3Coding
Return the middle value of a, b and c: the one that is neither the largest nor the smallest. If two values are equal, the middle value is determined by sorting, so [5, 5, 1] gives 5.
Example 1
- Input
- a = 3, b = 1, c = 2
- Output
- 2
Example 2
- Input
- a = 1, b = 2, c = 3
- Output
- 2
Example 3
- Input
- a = 5, b = 5, c = 1
- Output
- 5
Constraints
- -10^9 <= a, b, c <= 10^9
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.