Nlast

Given a [!scala]List[Int][/!][!java|python]recursive list[/!] and an integer N, return the list with only the N last elements.

Your solution should be linear in time, but you will probably need to define several functions to achieve that complexity.

The trick is to compute only once (and beforehand) how many elements you should keep.