码迷,mamicode.com
首页 >  
搜索关键字:leaves    ( 277个结果
树的遍历——A1004.Counting Leaves(30) 给出一棵树,问每一层有多少叶子节点(可DFS也可BFS)
#include <bits/stdc++.h> #include <stdio.h> #include <stdlib.h> #include <queue> using namespace std; const int maxn = 100010; struct node{ //bool lea ...
分类:其他好文   时间:2020-01-27 23:31:00    阅读次数:89
1325. Delete Leaves With a Given Value
Given a binary tree root and an integer target, delete all the leaf nodes with value target. Note that once you delete a leaf node with value target,  ...
分类:其他好文   时间:2020-01-22 11:06:54    阅读次数:64
PAT Advanced 1155 Heap Paths (30分)
In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the ...
分类:其他好文   时间:2020-01-17 21:13:06    阅读次数:93
preg_match绕过总结
preg_match绕过总结 什么是preg_match 绕过方法 1、数组绕过 preg_match只能处理字符串,当传入的subject是数组时会返回false 2、PCRE回溯次数限制 "PHP利用PCRE回溯次数限制绕过某些安全限制" 只需要 ...
分类:其他好文   时间:2020-01-15 19:42:50    阅读次数:380
1004 Counting Leaves (30分)
今天在热心网友的督促下完成了第一道PAT编程题。 太久没有保持训练了,整个人都很懵。 解题方法: 1.读懂题意 2.分析重点 3.确定算法 4.代码实现 该题需要计算每层的叶子节点个数,所以选用BFS 还有一个关键问题是 如何记录一层的开始和结束 另外,对于新手来说,图的存储也是一个知识点 容易忽略 ...
分类:其他好文   时间:2020-01-14 00:07:55    阅读次数:124
DS二叉树——二叉树之父子结点
题目描述 给定一颗二叉树的逻辑结构如下图,(先序遍历的结果,空树用字符‘0’表示,例如AB0C00D00),建立该二叉树的二叉链式存储结构。 编写程序输出该树的所有叶子结点和它们的父亲结点 输入 第一行输入一个整数t,表示有t个二叉树 第二行起,按照题目表示的输入方法,输入每个二叉树的先序遍历,连续 ...
分类:其他好文   时间:2020-01-11 20:03:38    阅读次数:117
1123. Lowest Common Ancestor of Deepest Leaves
link to problem Description: Given a rooted binary tree, return the lowest common ancestor of its deepest leaves. Recall that: The node of a binary tr ...
分类:其他好文   时间:2020-01-09 11:52:53    阅读次数:82
[LC] 404. Sum of Left Leaves
Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 1 ...
分类:其他好文   时间:2020-01-04 14:37:15    阅读次数:81
【leetcode】1302. Deepest Leaves Sum
题目如下: Given a binary tree, return the sum of values of its deepest leaves. Example 1: Constraints: The number of nodes in the tree is between 1 and 10 ...
分类:其他好文   时间:2019-12-29 10:38:07    阅读次数:72
1004_Counting Leaves (30分)[bfs/dfs]
bfs:记录层序 1 #include<iostream> 2 #include<vector> 3 #include<queue> 4 #include<map> 5 #include<set> 6 #include<cmath> 7 #include<cstdio> 8 #include<cst ...
分类:其他好文   时间:2019-12-26 14:43:22    阅读次数:77
277条   上一页 1 2 3 4 5 6 ... 28 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!