题解 | #从单向链表中删除指定值的节点#
从单向链表中删除指定值的节点
http://www.nowcoder.com/practice/f96cd47e812842269058d483a11ced4f
import java.util.*;
public class Main{
public static void main(String []args){
Scanner in = new Scanner(System.in);
int num = in.nextInt();
ArrayList<Integer> set = new ArrayList();
int head = in.nextInt();
set.add(head);
for(int i = 0;i<num-1;i++){
int value = in.nextInt();
int headInsert = in.nextInt();
int insertIndex = set.indexOf(headInsert);
set.add(insertIndex+1,value);
}
int deleteValue = in.nextInt();
set.remove(set.indexOf(deleteValue));
for(int i :set){
System.out.print(i+" ");
}
}
}