码迷,mamicode.com
首页 >  
搜索关键字:definition    ( 2735个结果
206反转链表
# Definition for singly-linked list.class ListNode: def __init__(self, x): self.val = x self.next = Nonea = ListNode(1)b = ListNode(2)a.next = b# 有关链表 ...
分类:其他好文   时间:2020-07-21 00:58:45    阅读次数:67
【刷题-LeetCode】222. Count Complete Tree Nodes
Count Complete Tree Nodes Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree from Wikipedia: In a com ...
分类:其他好文   时间:2020-07-20 15:46:54    阅读次数:80
leetcode-----99. 恢复二叉搜索树
链接:https://leetcode-cn.com/problems/recover-binary-search-tree/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode ...
分类:其他好文   时间:2020-07-19 11:36:41    阅读次数:70
leetcode-----100. 相同的树
链接:https://leetcode-cn.com/problems/same-tree/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...
分类:其他好文   时间:2020-07-19 11:33:58    阅读次数:44
[编程题] lc[236. 二叉树的最近公共祖先]
[编程题] lc:236. 二叉树的最近公共祖先 题目描述 输入输出例子 思路 使用后续遍历的思想,根据找到了左和右的情况,进行相应的返回结果。 Java代码 /** * Definition for a binary tree node. * public class TreeNode { * i ...
分类:其他好文   时间:2020-07-19 00:39:06    阅读次数:85
206.反转链表
原题链接 题解 利用双指针算法,直接让后面一个指向前面一个 代码如下 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x ...
分类:其他好文   时间:2020-07-18 22:12:35    阅读次数:56
从上到下打印二叉树 III
题解:层次遍历的基础上加个计数器,偶数层得到的结果反转一下 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeN ...
分类:其他好文   时间:2020-07-18 21:52:24    阅读次数:59
从上到下打印二叉树
解题:利用队列先进先出来实现层次遍历 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) ...
分类:其他好文   时间:2020-07-18 19:52:44    阅读次数:68
二叉树的镜像
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ ...
分类:其他好文   时间:2020-07-18 15:54:16    阅读次数:51
环形链表
题解:双指针 一个指针一次移动2步,一个指针一次移动一步。如果两个指针相遇证明存在环. /** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) ...
分类:其他好文   时间:2020-07-18 13:44:37    阅读次数:47
2735条   上一页 1 ... 9 10 11 12 13 ... 274 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!