25. Linked List: Basics-2

 remember to include edge cases in ques of linked list...
--------------------------------------------------------------------------------------------------------------------------

1.1 Deleting Head-

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

1.2 Deleting Tail-

delete the last element
but before that make sure you point the 2nd last element to null
hence, traverse the linked list and reach the 2nd last element

--------------------------------------------------------------------------------------------------------------------------
1.3 Deleting K-th node⭐

1. use a counter and reach (k-1)th node
2. make a pointer point to target node & also change links of prev node
3. handle edge cases of n=0, k=1, k>n

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

1.4 Deleting given elmt-

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

2.1 Inserting at start/end-

------------------------------------------------------------------------------------------------------------------------
2.2 Inserting at K-th pos⭐

----------------------------------------------------------------------------------------------------------------------------
2.3 Inserting before an element = x:

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

Comments

Popular posts from this blog

30.) DP on subsequences

36. Graphs-2 (traversal problems)

35. Graphs-1 (basics)