摘要: 题目描述 给定 n 个实数,求这n个实数在数轴上相邻2个数之间的最大差值,设计解最大间隙问题的线性时间算法(时间复杂度为O(n))。 给定 n 个实数,求这n个实数在数轴上相邻2个数之间的最大差值,设计解最大间隙问题的线性时间算法(时间复杂度为O(n))。 输入 第一行一个正整数n(2<=n<=2× 阅读全文
posted @ 2019-09-03 22:33 Osea 阅读(3096) 评论(0) 推荐(0) 编辑
摘要: 图片来源: https://blog.csdn.net/dylan_frank/article/details/78177368 【题意】: 对于每一个节点来说有多少对相同的子树。 【题解】: 利用层数进行hash,返回到对应的节点,最后标记后用等差数列来求出所有方案数。 1 #pragma GCC 阅读全文
posted @ 2019-09-03 21:48 Osea 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Parentheses 题目描述 Dave loves strings consisting only of '(' and ')'. Especially, he is interested in balanced strings. Any balanced strings can be cons 阅读全文
posted @ 2019-09-03 21:36 Osea 阅读(416) 评论(0) 推荐(0) 编辑
摘要: 题目描述 The people of a certain kingdom make a revolution against the bad government of the princess. The revolutionary army invaded the royal palace in 阅读全文
posted @ 2019-09-03 21:22 Osea 阅读(179) 评论(0) 推荐(0) 编辑