发表于 2013-7-30 16:44:26

[google面试题]Write
 a
 function
 to 
remove
 a 
single
 occurrence
 of
 an
 integer
 from
 a
 doubly
 linked
 list
 if
 it 
is 
present.

邢城 发表于 2013-7-30 17:03:46

Sample Answer(inJava):void remove(Node head, int value) { Nodecur = head; while (cur != null) { if(cur.value == value) { if(curr.prev != null) cur.prev.next = cur.next; if(cur.next != null) cur.next.prev = cur.prev; break; } cur= cur.next; }}
页: [1]
查看完整版本: [google面试题]Write
 a
 function
 to 
remove
 a 
single
 occurrence
 of
 an
 integer
 from
 a
 doubly
 linked
 list
 if
 it 
is 
present.