object ArrayExample {
def main(args: Array[String]): Unit = {
// Define the array
val arr = Array(1, 3, 7, 9, 2, 8, 5, 4)
// Create a slice of the array (from index 1 to 5, exclusive of 5)
val subset = arr.slice(1, 5) // This gives Array(3, 7, 9, 2)
// Find the maximum value in the subset
val max = subset.max
// Find the minimum value in the subset
val min = subset.min
println(s"Max: $max")
println(s"Min: $min")
}
}
/*
run:
Max: 9
Min: 2
*/