在一些涉及链表的面试题(如翻转、合并、排序链表)时,本题的基础代码可以作为模板。
#include <bits/stdc++.h>
using namespace std;
给定一个整数数组 nums,要求 先构建一个链表,然后遍历链表并输出所有元素。
输入共两行:
输出 n 个整数,每个数字占一行,按链表顺序输出。
4
2 7 11 15
2
7
11
15
3
3 2 4
3
2
4
By signing up a CodeFun2000 universal account, you can submit code and join discussions in all online judging services provided by us.