Problem title
Difficulty
Avg time to solve

Paths in a Maze
Easy
--
Positive Negative Pair
Easy
10 mins
Christmas Eve
Easy
15 mins
Letter Combinations of a Phone Number
Moderate
35 mins
Left Rotations of An Array
Moderate
10 mins
Minimum Time To Solve The Problems
Hard
50 mins
Implement a phone directory
Hard
50 mins
Longest Bitonic Sequence
Moderate
15 mins
Split A Circular Linked List
Easy
15 mins
Square Root Of An Integer
Easy
20 mins
6

Change Start Node

Difficulty: EASY
Contributed By
Anish De |Level 1
Avg. time to solve
20 min
Success Rate
85%

Problem Statement

You are given a singly linked list and an integer ‘K’. You are supposed to make ‘K’ th node from the end of a linked list as the starting node of the linked list.

Note :
Given ‘K’ will always be valid.
Input format :
The first line of the input contains the elements of the singly linked list separated by a single space and terminated by -1. Hence, -1 would never be a list element.

The second line contains a single integer ‘K’.
Output format :
Print updated list elements separated by space.
Node :
You do not need to print anything; it has already been taken care of.
Constraints :
1 <= N  <= 5*10^5
1 <= K <= N
-10^9 <= data <= 10^9 and data != -1

Time Limit : 1 sec
Sample Input 1:
7 11 13 17 19 23 29 -1
3
Sample Output 1:
19 7 11 13 17 23 29 -1
Explanation For Sample Input 1:
Removing the third node from the end of the linked list, i.e. 19 and make the head node of the linked list.
Sample Input 2:
13 1 19 3 9 -1
5
Sample Output 2:
13 1 19 3 9 -1
Reset Code
Full screen
copy-code
Console