title: Recursively find nth to last element in linked list
body: <p>I'm practicing basic data structure stuff and I'm having some difficulties with recursion. I understand how to do this through iteration but all of my attempts to return the nth node from the last of a linked list via recursion result in null. This is my code so far: </p>
  
  <pre><code>public static int i = 0; 
  public static Link.Node findnthToLastRecursion(Link.Node node, int pos) {
      if(node == null) return null; 
      else{
      findnthToLastRecursion(node.next(), pos);
      if(++i == pos) return node; 
      return null; 
      }
  </code></pre>
  
  <p>Can anyone help me understand where I'm going wrong here? </p>
  
  <p>This is my iterative solution which works fine, but I'd really like to know how to translate this into recursion: </p>
  
  <pre><code>public static Link.Node findnthToLast(Link.Node head, int n) {
      if (n &lt; 1 || head == null) {
          return null;
      }
      Link.Node pntr1 = head, pntr2 = head;
      for (int i = 0; i &lt; n - 1; i++) {
          if (pntr2 == null) {
              return null;
          } else {
              pntr2 = pntr2.next();
          }
      }
      while (pntr2.next() != null) {
          pntr1 = pntr1.next();
          pntr2 = pntr2.next();
      }
      return pntr1;
  }
  </code></pre>