真的是第一次完全没有看其他参考答案,第一次写出来,而且没有报错,值得庆祝一下。虽然题目很简单,但是我在使用递归时,还是害怕细节出错,ヾ(?°?°?)?? 求二叉树的高度 只要递归下去就可以了 1.map函数的使用,可以简化代码、 2.使用队列可以更加快速 ...
分类:
其他好文 时间:
2018-12-24 17:20:12
阅读次数:
150
Given an array A of integers, a ramp is a tuple (i, j) for which i < j and A[i] <= A[j]. The width of such a ramp is j - i. Find the maximum width of ...
分类:
其他好文 时间:
2018-12-24 02:59:49
阅读次数:
228
上学期转专业就没怎么学好数据结构,这学期正好看了算法导论第四章也有讲动态规划和,正好前不久做那个查找最长不重样字符串的题学了一个最短字符串匹配的动态图框法。用动态规划写了一下,分治还没写出来。 不止一次在if(x=1)这种问题上犯错了,要注意。有数组里只有一个数,和全是负数的情况要处理。 ...
分类:
其他好文 时间:
2018-12-24 02:35:39
阅读次数:
80
Given an array A of integers, a ramp is a tuple (i, j) for which i < j and A[i] <= A[j]. The width of such a ramp is j - i. Find the maximum width of ...
分类:
其他好文 时间:
2018-12-23 15:17:07
阅读次数:
169
tf.while_loop(cond,body,loop_vars,shape_invariants=None,parallel_iterations=10,back_prop=True,swap_memory=False,name=None,maximum_iterations=None,return_same_structure=False)当条件谓词cond为True,重复bodycond是
分类:
其他好文 时间:
2018-12-23 12:01:35
阅读次数:
482
果然我已经菜到被$div3$的题虐哭了 qwq 首先看到这个题,一个比较显然的想法就是先从1号点开始$dfs$一遍,然后通过一些奇怪的方式,再$dfs$一遍得到其他点的贡献。 那么具体应该这么做呢。 首先,我们维护两个数组$dis[i]$表示$i$到1的距离,$sum[i]$表示$i$的子树中的$v ...
分类:
其他好文 时间:
2018-12-23 11:26:08
阅读次数:
150
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Foll ...
分类:
其他好文 时间:
2018-12-23 11:08:05
阅读次数:
144
`RMQ(Range Minimum/Maximum Query)`,即区间最值问题。 对于长度为 的数列 ,回答若干查询 `RMQ(A,i,j)(i,j &A) { int n=A.size(); for (int i=0; i ...
分类:
其他好文 时间:
2018-12-22 19:35:23
阅读次数:
257
转自:http://blog.51cto.com/lee90/1788124 今天java开发在连接线上的oracle大量导数据,一会提示连接不上数据库了。我本地用sqldeveloper也连接不上。 登录到服务器,重启oracle,本地还是不能连接。 在xshell里面登录oracle # su ...
分类:
其他好文 时间:
2018-12-22 12:01:19
阅读次数:
372
题意: 给你一棵无根树,每个节点有个权值$a_i$,指定一个点u,定义$\displaystyle value = \sum^v a_i*dist(u,v)$,求value的最大值 n,ai<=2e5 思路: 其实就是找一个节点作为根满足上述最大的value 直接枚举是$O(n^2)$的,肯定不行, ...
分类:
其他好文 时间:
2018-12-22 11:44:58
阅读次数:
327