创建链表 递归方法: public class Solution { public ListNode ReverseList(ListNode head) { if(head == null || head.next == null) { return head; } ListNode preNode = ReverseList(head.next); head.next.next = head; head.next = null; return preNode; } } 判断是否是后序遍历 class Solution { bool judge(vector<int>& a, int l, int r){ if(l >= r) return true; int i = r; while(i > l && a[i - 1] > a[r]) --i; for(int j = i - 1; j >= l; --j) if(a[j] > a[r]) return false; return judge(a, l, i - 1) && (judge(a, i, r - 1)); } public: bool VerifySquenceOfBST(vector<int> a) { if(!a.size()) return false; return judge(a, 0, a.size() - 1); } };