You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Given a linked list with n nodes. Find the kth element from last without computing the length of the linked list.
7
+
8
+
// Input Format
9
+
// First line contains space separated integers representing the node values of the linked list. The list ends when the input comes as '-1'. The next line contains a single integer k.
10
+
11
+
// Constraints
12
+
// n < 10^5
13
+
14
+
// Output Format
15
+
// Output a single line containing the node value at the kth element from last.
16
+
17
+
// Sample Input
18
+
// 1 2 3 4 5 6 -1
19
+
// 3
20
+
// Sample Output
21
+
// 4
22
+
// Explanation
23
+
// The linked list is 1 2 3 4 5 6. -1 is not included in the list. So the third element from the last is 4
0 commit comments