We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
So, zipWithIndex produces pairs like
(28,0)
(32,1)
(5,2)
...
,where the second element is the index and the first the value in the list. Hold only those pairs for which the index is odd(filter), and return the first element of the pair which is the value(map) by applying the function which just describes holding only the first element of the pair.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Filter Positions in a List
You are viewing a single comment's thread. Return to all comments →
In Scala:
So, zipWithIndex produces pairs like (28,0) (32,1) (5,2) ...
,where the second element is the index and the first the value in the list. Hold only those pairs for which the index is odd(filter), and return the first element of the pair which is the value(map) by applying the function which just describes holding only the first element of the pair.