Given a linked list and a number n, rotate the linked list by n places. Submit your answer as pseudocode to fit as indicated below:
class Node {
def __init__(self, val, next=None) {
self.val = val
self.next = next
}
def __str__(self) {
current = self
ret = ''
while current {
ret += str(current.val)
current = current.next
}
}
def rotate_llist(llist, n) {
# YOUR ANSWER HERE
}
llist = Node(1, Node(2, Node(3, Node(4))))
print(rotate_llist(llist, 2));
# 3412