A .Little Pony and Expected Maximum pro:给定M,N,表示一个M面的骰子,甩N次,问出现的最大的数的期望。 sol:容斥,f(i)表示最大数<=i的期望,那么最大数=x的期望就是f(x)-f(x-1); B .Little Pony and Harmony Ch ...
分类:
其他好文 时间:
2019-03-04 21:01:52
阅读次数:
238
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l ...
分类:
其他好文 时间:
2019-03-04 09:31:18
阅读次数:
160
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally the function should: Note: Your algo ...
分类:
其他好文 时间:
2019-03-02 10:19:57
阅读次数:
182
常见面试题【问题1】为什么连接的时候是三次握手,关闭的时候却是四次握手? 答:因为当Server端收到Client端的SYN连接请求报文后,可以直接发送SYN+ACK报文。其中ACK报文是用来应答的,SYN报文是用来同步的。但是关闭连接时,当Server端收到FIN报文时,很可能并不会立即关闭SOC ...
分类:
其他好文 时间:
2019-02-26 21:09:35
阅读次数:
169
1.ReentrantLock是基于AQS实现的一种重入锁。 2.先介绍下公平锁/非公平锁 公平锁 公平锁是指多个线程按照申请锁的顺序来获取锁。 非公平锁 非公平锁是指多个线程获取锁的顺序并不是按照申请锁的顺序,有可能后申请的线程比先申请的线程优先获取锁。有可能,会造成优先级反转或者饥饿现象。 3. ...
分类:
其他好文 时间:
2019-02-26 19:14:21
阅读次数:
157
题目如下: We are given the root node of a maximum tree: a tree where every node has a value greater than any other value in its subtree. Just as in the pr ...
分类:
其他好文 时间:
2019-02-24 23:11:15
阅读次数:
346
Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead. Note:The sum of ...
分类:
其他好文 时间:
2019-02-24 10:27:27
阅读次数:
124
Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: I ...
分类:
其他好文 时间:
2019-02-24 10:25:23
阅读次数:
185
LCS--Longest Common Subsequence,即最长公共子序列,一般使用DP来解。 常规方法: dp[i][j]表示字符串s1前i个字符组成的字符串与s2前j个字符组成的字符串的LCS的长度,则当s1[i-1]==s2[j-1]时,dp[i][j]=dp[i-1][j-1],否则d ...
分类:
其他好文 时间:
2019-02-24 01:01:14
阅读次数:
194
```C++ include int main(){ int n, flag = 1, first_flag = 1, positive_flag = 0; int sum = 0, summax = 0; int st = 0, end = 0, st_max = 0, end_max = 0, ...
分类:
其他好文 时间:
2019-02-24 00:54:19
阅读次数:
163