Scala Programming: Find the maximum value from first, middle and last values of a given array of integers
Write a Scala program to find the maximum value from first, middle and last values of a given array of integers. Array length should be 1 and more and odd.
Sample Solution:
Scala Code:
Sample Output:
Orginal array: 2, 14, 5, 7, 9, Maximum value from first, middle and last values: 9 Orginal array: 22, 5, 5, 6, 1, Maximum value from first, middle and last values: 22 Orginal array: 2, 5, 17, 6, 9, Maximum value from first, middle and last values: 17
Scala Code Editor :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Scala program to check two numbers, 4 or 7 present in a given array of integers.
Next: Write a Scala program to find the common elements between two arrays of integers.
What is the difficulty level of this exercise?