MAXDIFFMIN - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: Tejas Pandey
Testers: Nishank Suresh, Takuki Kurokawa
Editorialist: Nishank Suresh

DIFFICULTY:

339

PREREQUISITES:

None

PROBLEM:

Given three integers A, B, C with A \lt B \lt C, find \max(A, B, C) - \min(A, B, C).

EXPLANATION:

Since A \lt B \lt C,

  • \max(A, B, C) = C
  • \min(A, B, C) = A.

So, the answer is C - A.

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    a, b, c = map(int, input().split())
    print(c-a)