题目地址:从上往下打印二叉树 题目描述 从上往下打印出二叉树的每个节点,同层节点从左至右打印。 题目示例 输入: {5,4,#,3,#,2,#,1} 返回值: [5,4,3,2,1] 解法分析 本题考查二叉树的广度遍历,可以借助队列先进先出的特点来保存结点。 代码 1 function PrintF ...
分类:
其他好文 时间:
2021-02-08 12:28:36
阅读次数:
0
A - A CodeForces - 994A You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the ro ...
分类:
其他好文 时间:
2021-02-08 12:25:39
阅读次数:
0
24. 两两交换链表中的节点 题目链接 直接换 class Solution { public ListNode swapPairs(ListNode head) { if(head == null) return null; if(head.next == null) return head; L ...
分类:
其他好文 时间:
2021-02-08 12:14:55
阅读次数:
0
链表的理论基础 链表结构 链表中的节点由数据域和指针域两部分组成。 //golang中单链表节点的定义 type ListNode struct{ Val int //数据域 Next *ListNode //指针域 } 链表的分类 单链表 链表的入口处称为链表的头节点head,链表的尾节点指向nu ...
分类:
其他好文 时间:
2021-02-08 11:44:41
阅读次数:
0
UOJ87 mx的仙人掌 这里没有用传统的方点外接圆点的做法,而是方点虚树上儿子跳到方点所在环上单调队列处理,本质上是一样的. code //爽! #include<bits/stdc++.h> using namespace std; typedef long long ll; const int ...
分类:
其他好文 时间:
2021-02-06 12:15:50
阅读次数:
0
队列的顺序存储 //顺环队列 头出尾进 #define MaxSize 100 struct QNode { ElementType Data[MaxSize]; int rear; //尾 int front; //头 }; typedef struct QNode *Queue; //入队列 v ...
分类:
其他好文 时间:
2021-02-06 11:58:48
阅读次数:
0
最简单的链表 1 typedef struct LNode *List; 2 struct LNode { 3 ElementType Data; 4 List Next; 5 }; 6 struct LNode L; 7 List PtrL; 8 9 //建立 10 11 //求表长 12 int ...
分类:
其他好文 时间:
2021-02-06 11:58:08
阅读次数:
0
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 typedef struct PolyNode *Polynomial; 5 struct PolyNode { 6 int coef; 7 int expon; 8 Polynomial link; 9 ...
分类:
其他好文 时间:
2021-02-06 11:57:04
阅读次数:
0
#include <iostream> #include <stdlib.h> using namespace std; typedef int DataType; //使int重命名为DataType DataType flag = 0; //flag是用来判断神魔时候输入数据结束 typedef ...
分类:
其他好文 时间:
2021-02-06 11:52:00
阅读次数:
0
数组重复元素之类问题的整理 lt26 删除排序数组重复项 主要是原地删除,O(1) 空间,很是巧妙 func removeDuplicates(nums []int) int { //O(1)空间复杂 if len(nums)==0{ return 0 } tmp:=0 //不同,tmp+1,放在相 ...
分类:
其他好文 时间:
2021-02-06 11:42:42
阅读次数:
0