注意,题目要求要保持两部分的相对顺序,所以,用交换是不行的. import java.util.HashSet; import java.util.Set; class ListNode{ int val; ListNode next; ListNode(int x){ val = x; } } public class Solution{ public static void main(String[] args){ ListNode head = new ListNode(3); head.…
[002-Add Two Numbers (单链表表示的两个数相加)] 原题 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. In…
Given a linked list and two values v1 and v2. Swap the two nodes in the linked list with values v1 and v2. It's guaranteed there is no duplicate values in the linked list. If v1 or v2 does not exist in the given linked list, do nothing. Notice You sh…