链接:https://leetcode-cn.com/problems/unique-binary-search-trees/ 代码 class Solution { public: int numTrees(int n) { vector<int> f(n + 1); f[0] = 1; for ...
分类:
其他好文 时间:
2020-07-18 11:25:21
阅读次数:
56
此题和之前的剑指offer32-I、II.从上到下打印二叉树大致相同在BFS的基础上只是添加了一个重排序的过程。具体代码如下: 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * st ...
分类:
其他好文 时间:
2020-07-18 11:18:07
阅读次数:
58
indexOf() 方法返回字符串中指定文本首次出现的索引(位置) 找不到返回-1 lastIndexOf() 方法返回指定文本在字符串中最后一次出现的索引 找不到返回-1 search() 方法搜索特定值的字符串,并返回匹配的位置 split() 将字符串转换为数组 slice() 提取字符串的某 ...
分类:
其他好文 时间:
2020-07-17 22:23:24
阅读次数:
73
题目链接 题目大意:给出一颗含有$n$个结点的树,每个节点有一个颜色。求树中每个子树最多的颜色的编号和。 树上启发式合并(dsu on tree)。 我们先考虑暴力怎么做。遍历整颗树,暴力枚举子树然后用桶维护颜色个数。这样做是$O(n^2)$的,显然会T。我们需要一种更快的算法:树上启发式合并。 关 ...
分类:
其他好文 时间:
2020-07-17 22:21:39
阅读次数:
58
命名py脚本时,不要与python预留字,模块名等相同,即Python文件名不要使用Python系统库的名字,就是因为使用了Python系统库的名字,所以在编译的时候才会产生.pyc文件。正常的Python文件在编译运行的时候是不会产生.pyc文件的! 这类问题的解决方法则是:更改python脚本的 ...
分类:
其他好文 时间:
2020-07-17 19:27:07
阅读次数:
76
1,讲分词器的文件夹放入es安装包的plugins,重新启动elasticsearch //查询es运行中的进程pid ps -aux|grep elasticsearch //杀死进程 kill -9 pid //使用es账户启动 nohup ./elasticsearch & 2,重启es,然后 ...
分类:
其他好文 时间:
2020-07-17 16:22:28
阅读次数:
69
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), r ...
分类:
其他好文 时间:
2020-07-17 13:55:38
阅读次数:
71
源码编译安装 http://nginx.org/en/download.html 到官网下载,然后用XFTP上传到root目录 把文件解压出来 tar -zxvf nginx-1.16.0.tar.gz 然后用yum安装依赖项 yum install gcc pcre-devel zlib-deve ...
分类:
其他好文 时间:
2020-07-17 09:27:00
阅读次数:
72
强烈推荐视频: 堆排序(heapsort) 代码: #include <iostream> #include <stdlib.h> using namespace std; void heapify(int tree[], int n, int i) { if (i >= n) return; in ...
分类:
编程语言 时间:
2020-07-17 01:23:04
阅读次数:
99
题目链接:https://leetcode-cn.com/problems/n-ary-tree-postorder-traversal/ 方法一递归法:先访问子节点,然后访问根。LeetCode代码: /* // Definition for a Node. class Node { public ...
分类:
其他好文 时间:
2020-07-16 21:39:10
阅读次数:
79