就是把输入给的左孩子右孩子互换一下,然后输出层次遍历和中序遍历. #include <iostream> #include <algorithm> #include <cstring> #include <string.h> #include <cstdio> #include <queue> using namespace std; ; bool first=true; struct Node{ int id; int left;…
题目 The following is from Max Howell @twitter: Google: 90% of our engineers use the sofware you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck of. Now it's your turn to prove that YOU CAN invert a binary tree! Input Speci…
The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off. Now it's your turn to prove that YOU CAN invert a binary tree! Input Specif…
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<stack> #include<algorithm> using namespace std; struct Node { int left; int right; }s[]; int n;…
题意: 输入一个正整数N(<=10),接着输入0~N-1每个结点的左右儿子结点,输出这颗二叉树的反转的层次遍历和中序遍历. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ][]; ]; void bfs(int r){ queue<int>q; q.push(r); cout<<r; while(!q.empty()){ in…
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90577042 1102 Invert a Binary Tree (25 分)   The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary…
1102 Invert a Binary Tree The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off. Now it's your turn to prove that YOU CAN invert a…
1102 Invert a Binary Tree(25 分) The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off. Now it's your turn to prove that YOU CAN in…
The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off. Now it's your turn to prove that YOU CAN invert a binary tree! Input Specif…
水题一个,贴个代码吧. #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <string> #include <map> using namespace std; ; map<string,int> maps; int main() { int n,m,s; string str; scanf(&q…