算法
xia0gui
好好学习,天天向上。
展开
-
LeetCode206 反转一个单链表
LeetCode206 反转一个单链表。 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL 算法: 遍历链表,更改当前Node->next为前一个Node的地址(更改前进行保存)。 /** * Definition for singly-linked list. * stru...原创 2018-09-22 20:33:50 · 264 阅读 · 0 评论 -
563. 二叉树的坡度
一、 class Solution: def findTilt(self, root): """ :type root: TreeNode :rtype: int """ self.ans = 0 def subTreeSum(root原创 2019-03-04 21:47:11 · 118 阅读 · 0 评论 -
二叉树前序、中序和后序遍历
Binary Tree Inorder Traversal 二叉树的中序遍历 解法一:递归 // Recursion class Solution { public: vector inorderTraversal(TreeNode *root) { vector res; inorder(root, res); return res; } void inorder(TreeNode *root...原创 2019-03-03 10:19:41 · 100 阅读 · 0 评论