title: Finding the "Nth node from the end" of a linked list
body: <p>This seems to be returning the correct answer, but I'm not sure if this is really the best way to go about things.  It seems like I'm visiting the first n nodes too many times.  Any suggestions?  Note that I have to do this with a singly linked list.</p>
  
  <pre><code>Node *findNodeFromLast( Node *head, int n )
  {
      Node *currentNode;
      Node *behindCurrent;
      currentNode = head;
      for( int i = 0; i &lt; n; i++ ) {
          if( currentNode-&gt;next ) {
              currentNode = currentNode-&gt;next;
          } else {
              return NULL;
          }
      }
  
      behindCurrent = head;
      while( currentNode-&gt;next ) {
          currentNode = currentNode-&gt;next;
          behindCurrent = behindCurrent-&gt;next;
      }
  
      return behindCurrent;
  }
  </code></pre>