Why {1,2} 3 expected {1,2}?

  • 2

    Does anyone know how to deal with k > length of the list?

  • 4

    See this sentence in description.

    If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.

    In terms of this test case, considering {1, 2} as the left-out nodes. So, just remain them.

    In general, if k > length of the list, we don't need to do anything.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.