You are viewing a single comment's thread. Return to all comments →
Strange that is it not working, I am getting the output as 15, but the answer is 16.
Based on the input the answer should be 15, So, I don't know whats wrong with my code. This is in scala!!
def f(arr:List[Int]):Int = arr.zipWithIndex.filter(_._2%2 == 1).map(_._1).sum
Seems like cookies are disabled on this browser, please enable them to open this website
Sum of Odd Elements
You are viewing a single comment's thread. Return to all comments →
Strange that is it not working, I am getting the output as 15, but the answer is 16.
Based on the input the answer should be 15, So, I don't know whats wrong with my code. This is in scala!!