Question
Its dark and raining, and Jojo is visiting a small town in Germany to help the local police solving a mysterious case of missing children
Its dark and raining, and Jojo is visiting a small town in Germany to help the local police solving a mysterious case of missing children near a cave. To help his investigation, Jojo decided to use a time machine. Using the time machine Jojo travelled to N different years, and now Jojo wants to know the smallest difference between two different years he has visited. Help Jojo to answer this question!
Format Input
The first line contains a single number T, the number of testcases. Each testcase contains a number N, which is the number of years Jojo has visited. The next N lines contain A i which is the i-th year Jojo has visited using the time machine.
Format Output
For each testcase, output one line starting with Case # X: (without quotes) where X is the testcase number (starting from 1) followed by the smallest difference between two different years Jojo has visited.
Constraints
1 T 100
2 N 100
1 Ai 1000000
All values of Ai in a testcase are different
Sample Input 1 (standard input)
2
3
2019
1986
1953
7
1945
2020
2055
1919
2013
1975
2000
Sample Output 1 (standard output)
Case #1: 33
Case #2: 7
Explanation
On the first testcase, this is the difference between every pair of years Jojo has visited:
The difference of 1953 and 1986 is 33 years.
The difference of 1953 and 2019 is 66 years.
The difference of 1986 and 2019 is 33 years.
The smallest difference is 33 years, which is between 1953 and 1986, or between 1986 and 2019.
On the second testcase, the smallest difference is 7 years which is between 2013 and 2020.
NOTE:
USE C PROGRAMMING
\USE STUDIO.H and STRING.H
PAY ATTENTION TO CONSTRAINTS
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started