We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None
Big-O
The text was updated successfully, but these errors were encountered:
Logic
class Solution: def deleteNode(self, node): next_ = node.next node.val = next_.val node.next = next_.next
Sorry, something went wrong.
def removeNthFromEnd(self, head: Optional[ListNode], n: int) -> Optional[ListNode]: left = head node_count = 1 while left: if left.next: node_count += 1 left = left.next else: break base = head nth = node_count - n - 1 cnt = 0 if nth + 1 <= 0: base = base.next return base while base: if cnt == nth: base.next = base.next.next break base = base.next cnt += 1 return (head)
def store(lnode): vals = [] while lnode: vals.append(lnode.val) lnode = lnode.next return vals[::-1]
No branches or pull requests
Initialization of singly-linked list
Big-O
The text was updated successfully, but these errors were encountered: