//题目1028:继续畅通工程 #include<iostream> #include<algorithm> using namespace std; int Tree[1010]; int findRoot(int x){ if(Tree[x]==-1) return x; else { int tmp=findRoot(Tree[x]); Tree[
Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification: Each input file contains one test case. For each case, the first line contains two
注释部分为傻乎乎比较法 #include<stdio.h>#include<stdlib.h>#include<string.h>//typedef struct people{// char name[6];// int year;// int month;// int day;//}people;////int judge(int year,in
Problem Description “Well, it seems the first problem is too easy. I will let you know how foolish you are later.” feng5166 says. “The second problem is, given an positive integer N, we define an eq
leetcode 1028. Recover a Tree From Preorder Traversal 题意:给一个二叉树的深度优先的前序遍历,重建一颗二叉树。 输入:"1-2--3--4-5--6--7" 输出:[1,2,5,3,4,6,7] 思路:主要的难点是5的父节点是1,这里考虑用stack保存,当前节点以及节点所在的层数。 通过更新栈顶元素,来找当前点的父节点。 代码: