0
点赞
收藏
分享

微信扫一扫

leetcode-19-Remove Nth Node From End of List

蛇发女妖 2023-08-23 阅读 60


Use a common trick call slow, fast pointer. Because the last n means the distance between last n and the end is n, so we create two pointer, the first is slow, and second is fast, and make fast to n step. And then go thought the list with slow and fast until fast meet the end. At that time, slow ->next is the node we want to delete.


举报

相关推荐

0 条评论