1. For this question, you need to complete the method as
shown below. The method receives a parameter of a nonempty list of integers and returns true if there is a place to
split the list so that the sum of the numbers on one side is
equal to the sum of the numbers on the other side. For
instance, given the list (1, 5, 3, 3) would return true since it
is possible to split in the middle as well as 1 + 5 is equal to
3 + 3. Another example is (7, 3, 4), it also should return
true because 3 + 4 = 7. Identify correct Scala statements
for the lines (1) and (2). HINT) In every iteration, the
firsthalf is adding an item and the secondhalf is subtracting
the item for conducting the comparison between the
firsthalf and the secondhalf.
def balanceCheck(list: List[Int]): Boolean = {
var firsthalf = 0
var secondhalf = list.sum
for (i <- Range(0, list.length)){
_____________________________(1)
_____________________________(2)
if (firsthalf == secondhalf) {
return true
}
}
return false
}