GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday, 26 October 2022

[Solution] Max minus Min CodeChef Solution



Problem

Chef is given 3 integers A, B, and C such that A \lt B \lt C.

Chef needs to find the value of max(A, B, C) - min(A, B, C).

Here max(A, B, C) denotes the maximum value among A, B, C while min(A, B, C) denotes the minimum value among A, B, C.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of 3 integers A, B, C.

Output Format

For each test case, output the value of max(A, B, C) - min(A, B, C).


Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Explanation:

Test case 1: Here, max(1, 3, 10) = 10 and min(1, 3, 10) = 1. Thus, the difference is 9.

Test case 2: Here, max(5, 6, 7) = 7 and min(5, 6, 7) = 5. Thus, the difference is 2.

Test case 3: Here, max(3, 8, 9) = 9 and min(3, 8, 9) = 3. Thus, the difference is 6.

Test case 4: Here, max(2, 5, 6) = 6 and min(2, 5, 6) = 2. Thus, the difference is 4.

No comments:

Post a Comment