Rotated List

Question (LC.61)

Given a list, rotate the list to the right by k places, where k is non-negative.

Example

Input: 1->2->3->4->5->null, k = 2
Output: 4->5->1->2->3->null

Analysis

How do we get to the ith node in singly linked list?

results matching ""

    No results matching ""