If K equals list length - no rotation is actually required. Proposed code is not handling such situation and I suppose it will throw an NRE exception or return null as a result depending on implementation.
For example list is 1-2-3, and K=3
Here we will have head as null:
for (int i = 0; i < skipLength - 1; i++)
lastNodeOfRotatedList = lastNodeOfRotatedList.next;
// ‘lastNodeOfRotatedList.next’ is pointing to the sub-list of ‘k’ ending nodes
head = lastNodeOfRotatedList.next;
lastNodeOfRotatedList.next = null;
return head;
Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Solution Review: Problem Challenge 2 - Grokking the Coding Interview: Patterns for Coding Questions