对A1135这题有心里阴影了,今天终于拿下AC.学习自柳神博客:https://www.liuchuo.net/archives/4099 首先读题很关键: There is a kind of balanced binary search tree named red-black tree in the data structure……………… 红黑树首先应该是一棵BST树,不然从何谈起维护二分查找结构? 所以第一步就应该根据先序遍历以及BST树的特性来判断是否是一棵BST树,然后根据这两个条
326. Power of ThreeGiven an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? 看到这种题目,第一想法就是用递归或者循环来做,但是题目要求了不能用这种方法来做,所以只能另想他法. 假设输入一个数 n,如果 n 是3的幂,那么 3^x = n, 即 x = log10
#include <iostream> using namespace std; struct Tree { int data; Tree *lchild; Tree *rchild; }tree; Tree *Create(int a1[],int b1[],int n) { int k; ) return NULL; ]; Tree *bt=(Tree *)malloc(sizeof(Tree)); bt->data=root; ;k<n;k++) { if(b1[k]==ro
var tag=document.getElementsByTagName('body')[0]; function findChild(tag){ var child=tag.childNodes,type,result=[]; for(var i=0;i<child.length;i++){ type=child[i].nodeType; if(type==3){ result+=child[i].nodeValue }else if(type==1){ result+=findChild