摘要:
1.删除排序数组中的重复项 思路解析:本题的主要目的是删除重复项,限制是:1.数组是排序数组;2.必须原地修改;那其实只需要遍历然后把不同项前移 代码: class Solution { public int removeDuplicates(int[] nums) { int i = 0, j = 阅读全文
摘要:
题意:给定n个数构建完全二叉树,输出完全二叉树的层序遍历 思路:二叉树的中序遍历建树即为输出 #include<cstdio> #include<queue> #include<vector> #include<algorithm> using namespace std; const int N 阅读全文
摘要:
#include<cstdio> #include<queue> #include<vector> using namespace std; const int N = 110; int n; struct node{ int layer; bool isleaf = true; vector<in 阅读全文
摘要:
层序遍历进行layer的确定 #include<cstdio> #include<vector> #include<math.h> #include<queue> using namespace std; const int N = 100010; const int INF = 100010; i 阅读全文