将链表中的数据提取到带有序号的映射中,然后将节点交换,最后按交换后的顺序放入向量中组合成符合题目要求的链表。 /** * struct ListNode { * int val; * struct ListNode *next; * ListNode(int x) : val(x), next(nullptr) {} * }; */ class Solution { private: map<int, ListNode*> map; vector<ListNode*> list; int group = 0; int length = 0; int count = 0;...