Created
May 31, 2016 17:35
-
-
Save adarsh0806/02d8e1d54d510294e75dfbc0d9bd7059 to your computer and use it in GitHub Desktop.
delete_first
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def delete_first(self): | |
deleted = self.head | |
if self.head: | |
self.head = self.head.next | |
deleted.next = None | |
return deleted |
Great solution
…On Fri, 12 Jan 2024, 00:27 lator, ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Compared to most solution, I think I was too explicit
def delete_first(self):
if self.head:
old_head = self.head
if self.head.next:
new_head = self.head.next
self.head = new_head
old_head.next = None
else:
self.head = None
return old_head
return None
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/adarsh0806/02d8e1d54d510294e75dfbc0d9bd7059#gistcomment-4827398>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWKPMQYFPAPCNK72KSSDLNDYOBYPXBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVAZTMMZRHEYDENVHORZGSZ3HMVZKMY3SMVQXIZI>
.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compared to most solution, I think I was too explicit