题目:如何查找单链表的倒数第n个指针。
算法一:第一次遍历到链表末尾,找到链表长度N;第二遍遍历,找到第N-n个节点。
算法二:设立两个指针,p1指向头节点,p2往前走n步,这样,p2与p1之间间隔n个指针。这样,当p2到达末尾是,p1则为倒数第N-n个节点。

Move Zeroes

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. For exa...

阅读全文

Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not ...

阅读全文

Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space...

阅读全文