题意:找出文本串中字典序第 k 大的字符串 思路: 首先我们不能仅仅按后缀数组排完序后每个字符串的大小来找,因为重复字符也参与排名,比如 AAB 2, 结果是 A 而不是 AA。 注:以下第 i 个后缀均指排完序后第 i 小的后缀。 所以我们二分找第 k 大的字符串位于哪个区间,假定我们现在确定目标 ...
分类:
编程语言 时间:
2020-07-17 22:05:37
阅读次数:
71
/** * 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
Tom and Jerry are going on a vacation. They are now driving on a one-way road and several cars are in front of them. To be more specific, there are nn ...
分类:
其他好文 时间:
2020-07-17 09:30:42
阅读次数:
82
强烈推荐视频: 堆排序(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
Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a ...
分类:
其他好文 时间:
2020-07-17 01:14:23
阅读次数:
90
题目链接: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
一个数最多能取8-9次根号。 #include <bits/stdc++.h> using namespace std; #define debug printf("bug!!!\n"); typedef long long ll; const int MAXN=1e5+10; const ll M ...
分类:
其他好文 时间:
2020-07-16 10:11:53
阅读次数:
74
链接:https://leetcode-cn.com/problems/subsets-ii/ 代码 class Solution { public: vector<vector<int>> ans; vector<int> path; vector<vector<int>> subsetsWith ...
分类:
其他好文 时间:
2020-07-16 00:27:10
阅读次数:
75
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { ...
分类:
其他好文 时间:
2020-07-16 00:01:06
阅读次数:
61
# 二叉搜索树的特点是左子树小于根节点,右子树大于根节点。# 因此当根节点为i的时候,左子树的值为1:i-1,右子树为i+1:n# 当节点为n的时候所有的能够组成的树为左子树个数乘以右子树个数。class Solution: def numTrees(self, n: int) -> int: dp ...
分类:
其他好文 时间:
2020-07-15 23:51:44
阅读次数:
62