<>● 请你手写代码，如何合并两个有序链表

class Solution { public: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
if(l1 == NULL) { return l2; } if(l2 == NULL) { return l1; } if(l1->val < l2->val
) { l1->next=mergeTwoLists(l1->next,l2); return l1; } else { l2->next=
mergeTwoLists(l1,l2->next); return l2; } } };
<>● 手写代码：反转链表

Void reversal_list(mylist * a_list) { mylist * forward_node = nullptr; mylist
* cur_node= a_list->next; mylist* next_node = cur_node->next; if(cur_node ==
nullptr) { return ; } while(1) { cur_node->next = forward_node; forward_node =
cur_node; cur_node = next_node; if(cur_node == nullptr) { break; } next_node =
cur_node->next; } a_list->next = forward_node; }
<>● 判断一个链表是否为回文链表，说出你的思路并手写代码

bool is_palindromic_list2(mylist *a_list) { if(a_list == nullptr) { return
false; } stack<int>list_value; mylist * fast =a_list; mylist *slow =a_list;
while(fast->next!=nullptr && fast->next->next!=nullptr) { list_value.push(slow->
next->value); slow = slow->next; fast = fast->next->next; } cout<<"middle elem
value is "<<slow->next->value<<endl; if(fast->next != nullptr) { cout<<"the
list has odd num of node"<<endl; slow =slow->next; } int cur_value; while(!
list_value.empty()) { cur_value = list_value.top(); cout<<"stack top value is"<<
cur_value<<endl; cout<<"list value is "<<slow->next->value<<endl; if(cur_value
!= slow->next->value) { return false; } list_value.pop(); slow = slow->next; }
return true; }
<>● 请你手写链表反转

struct ListNode { int val; struct ListNode *next; ListNode(int x) :val(x), next
next; while(p) { p->next=pre; pre=p; p=next; if(next) next=next->next; } return
pre; }
<>● 请问什么是单向链表，如何判断两个单向链表是否相交

1、单向链表

2、判断两个链表是否相交

1）方法1：

2）方法2：