
Maximum Difference Problem Statement
Given an array ARR
of N
elements, your task is to determine the maximum difference between any two elements in ARR
.
If the maximum difference is even, print EVEN
. If the maximum difference is odd, print ODD
.
Input:
The first line of input contains an integer T
denoting the number of test cases. Each test case consists of two lines:
- The first line contains an integer N
, the size of the array ARR
.
- The second line contains N
space-separated integers representing the elements of ARR
.
Output:
For each test case, print EVEN
if the maximum difference is even, otherwise print ODD
. Each result should be on a new line.
Example:
Input:
ARR = [1, 10, 5, 2, 8, 1]
Output:
ODD
Explanation:
The maximum difference is between 10 and 1, which is 9. Since 9 is odd, the output is ODD
.
Constraints:
1 <= T <= 100
1 <= N <= 5000
1 <= ARR[i] <= 10^9
Time limit: 1 sec.
Note:
You are not required to print anything. Implement the function to return the correct result.

AnswerBot
6d

Find the maximum difference between any two elements in an array and determine if it is even or odd.
Iterate through the array to find the maximum and minimum elements.
Calculate the difference between ...read more

Help your peers!
Add answer anonymously...
Top Capgemini Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in Capgemini Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app