kucheasysa

Algoverse_adesh_42

Jul 11th, 2024
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. class Solution:
  2.     def delete_node(self, head, x):
  3.         #code here
  4.         current = head
  5.         indexx = 1
  6.         while head != None:
  7.             if indexx == x:
  8.                 nex = head.next
  9.                 pre = head.prev
  10.                 if pre != None:
  11.                     pre.next = nex
  12.                 else:
  13.                     current = nex
  14.                 break
  15.             indexx += 1
  16.             head = head.next
  17.         return current
  18.        
  19.  
Advertisement
Add Comment
Please, Sign In to add comment