题解 | #从单向链表中删除指定值的节点#
从单向链表中删除指定值的节点
https://www.nowcoder.com/practice/f96cd47e812842269058d483a11ced4f
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n, head, del; vector<int> list; cin >> n >> head; list.push_back(head); while(n-- > 1){ int front, behind; cin >> behind >> front; auto it = find(list.begin(), list.end(), front); list.insert(it+1, behind); } cin >> del; for(int it : list){ if(it != del) cout << it << " "; } return 0; }