Maximum Difference

You are given an array 'ARR' of the 'N' element. Your task is to find the maximum difference between any of the two elements from 'ARR'.

If the maximum difference is even print “EVEN” without quotes. If the maximum difference is odd print “ODD” without quotes.

For example:

Given 'ARR' = [1, 10, 5, 2, 8, 1 ] , answer is "ODD".
Here the maximum difference is between 10 and 1, 10 - 1 = 9
Input Format:
The first line of input contains an integer T’ denoting the number of test cases to run. Then the test case follows.

The first line of each test case contains ‘N’, the length of the array 'ARR'.

The second line of each test case contains ‘N’ space-separated elements of 'ARR'.
Output Format:
For each test case, print a single line containing “ODD” without quotes if the maximum difference is odd else print “EVEN” without quotes.

The output for each test case is printed in a separate line.
Note:
You don’t need to print anything. It has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 100
1 <= N <= 5000 
1 <= ARR[i] <= 10 ^ 9

where ‘N’ is the length of the array 'ARR', and 'ARR[i]' is an element of the 'ARR' respectively.

Time limit: 1 sec.
CodingNinjas
author
2y
Find Max And Min

We will iterate over ARR and find the MAX and MIN of the ARR. And if the MAX - MIN is odd the return “ODD” else return "EVEN".

The algorithm will be-

  1. MAX = -1, MIN= 10 ^ 9 + 1
  2. For VAL in...read more
Help your peers!
Add answer anonymously...
Raja Software Labs Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter