#C1956. Maximum Difference in Comma-Separated Integers
Maximum Difference in Comma-Separated Integers
Maximum Difference in Comma-Separated Integers
You are given a string of comma-separated integers. Your task is to compute the maximum difference between any two integers in the list. In other words, if the list of numbers is \(a_1, a_2, \ldots, a_n\), then you should output \(\max(a_1, a_2, \ldots, a_n) - \min(a_1, a_2, \ldots, a_n)\).
Note: The input will always have at least one integer and the integers are separated by commas (",").
inputFormat
The input consists of a single line containing a comma-separated list of integers.
Example: 3,10,6,-5,-2
outputFormat
Output a single integer representing the maximum difference between any two integers in the list.
For the sample input above, the output is 15
.
3,10,6,-5,-2
15