GFG-POTD | Remove every Kth Node using Java | Practice | 29 April 2024 | LinkedList| Data Structures

preview_player
Показать описание
Geeks-for-Geeks | Practice Problem
29 April 2024
Problem : Remove every Kth Node using Java
Level : Easy
Topic Tag : Linked List | Data Structures

------------------------------

You may also visit my another playlists :

LeetCode Problems :

Code360 by coding ninja's mcq solution :

-----------------------

Description about the problem as follows :

Given a singly linked list having n nodes, your task is to remove every kth node from the linked list.

Example 1:

Input:
n = 8
linked list: 1--+ 2 --+ 3 -+ 4 -+ 5 -+ 6 -+ 7 -+8
k = 2

Output:
1 --+ 3 --+ 5 --+ 7

Explanation:
After removing every 2nd node of the linked list, the resultant linked list will be: 1 -+ 3 -+ 5 -+ 7.

Example 2:

Input:
n = 10
linked list: 1 --+ 2 --+ 3 --+ 4 --+ 5 --+ 6 --+ 7 --+ 8 --+ 9 --+ 10
k = 3

Output:
1 --+ 2 --+ 4 --+ 5 --+ 7 --+ 8 --+ 10

Explanation:
After removing every 3rd node of the linked list, the resultant linked list will be: 1 --+ 2 --+ 4 --+ 5 --+ 7 --+ 8 --+ 10.

Your Task:
The task is to complete the function deleteK() which takes head of linked list and integer k as input parameters and delete every kth node from the linked list and return its head.

Expected Time Complexity : O(n)
Expected Auxiliary Space : O(1)

---------------------------------

Please subscribe the channel

Like and Share the video

Thank you for watching the video

______________________________

#removeeverykthnodeproblemofthedaygfg
#gfgproblemoftheday
#problemofthedaygfgusingjava
#removeeverykthnodeusingjava
#gfgpotd29april2024
#practiceproblemgfg
#removeeverykthnodegfgproblemoftheday
#linkedlists
#datastructures
Рекомендации по теме
visit shbcf.ru