Again, we’ll consider two cases while writing our code:
Node to be deleted is at position 0
Node to be deleted is not at position 0
The overall logic will stay the same as in the previous lesson except that we’ll change the code a bit to cater to position rather than a key.
Implementation
Without any further ado, let’s jump to the implementation: