All pastes #470050 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-04 01:05 UTC
rendered paste body
/** Remove a node from the list. **/
  public static void remove(int num, Node head) {
    Node temp = head;
    temp.data = num;
    
    if (head.equals(temp)) {
      head = head.next;
      return;
    }
    Node p = head, q = null;
    while ((q = p.next) != null) {
      if (head.equals(q)) {
        p.next = q.next;
        return;
      }
      p = q;
    }
  }