Find the nth to last element of a singly linked list. The minimum number of nodes in list is n. Example Given a List ->->->->, . Runner Technique: 两个指针都从Dummy node出发,结束条件是runner.next!=null public class Solution { /** * @param head: The first n…
Find the nth to last element of a singly linked list. The minimum number of nodes in list is n. Example Given a List 3->2->1->5->null and n = 2, return node whose value is 1. 分析: 要找到nth to last element,我们需要两个指针,第一个指针先走n步,然后两个指针同时走,知道第一个指针为nu…
Description Find the nth to last element of a singly linked list. The minimum number of nodes in list is n. Example Given a List 3->2->1->5->null and n = 2, return node whose value is 1. 解题:给一个链表,求倒数第n个结点的值.先贴一下自己的代码,思路比较简单,遍历两遍,第一遍算结点总数,推出所…
题目: Given a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given value in the binary search tree, do nothing. You should keep the tree still a binary search tree after rem…
Yet Another Source Code for LintCode Current Status : 232AC / 289ALL in Language C++, Up to date (2016-02-10) For more problems and solutions, you can see my LintCode repository. I'll keep updating for full summary and better solutions. See cnblogs t…