链表反转2种方法
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* reverseList(ListNode* head) {
/*方法一 采用头插法*/
原创
2020-08-05 16:28:55 ·
101 阅读 ·
0 评论