今際の国の呵呵君
Sunday, January 11, 2015
[LeetCode]Remove Nth Node From End of List
双指针找到倒数第N + 1个节点,然后通过这个这节点删除倒数第N个节点。注意head有可能会被删除,我们需要用一个helper节点来帮我们keep track of新的head。O(N)时间,常数空间。代码如下:
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment