核心部分 NIO( New Input/ Output) , 引入了一种基于通道和缓冲区的 I/O 方式,NIO 是一种同步非阻塞的 IO 模型。同步是指线程不断轮询 IO 事件是否就绪,非阻塞是指线程在等待 IO 的时候,可以同时做其他任务。同步的核心就是 Selector,Selector 代替 ...
分类:
编程语言 时间:
2020-06-08 19:08:32
阅读次数:
53
Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: Input: [0,1] Output: 2 Explanation: [0 ...
分类:
其他好文 时间:
2020-06-04 01:36:55
阅读次数:
59
问题: 给定一个山峦分布数组,元素值代表高度。 假设score分值=两山高度和-两山距离=A[i]+A[j]-(j-i)=A[i]+A[j]+i-j 求这个分值最高是多少? Example 1: Input: [8,1,5,2,6] Output: 11 Explanation: i = 0, j ...
分类:
其他好文 时间:
2020-06-02 14:47:22
阅读次数:
53
问题: 给定数组,求满足锯齿形子数组<连续两两元素的增减关系为:增减依次循环出现>的最大长度。 Example 1: Input: [9,4,2,10,7,8,8,1,9] Output: 5 Explanation: (A[1] > A[2] < A[3] > A[4] < A[5]) Examp ...
分类:
其他好文 时间:
2020-06-01 13:46:46
阅读次数:
54
Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 1 ...
分类:
其他好文 时间:
2020-06-01 13:37:24
阅读次数:
62
Hello 各位,这里是新治的第二篇博客,今天要解的这道题是LeetCode第七题,整数反转,先来读一下题: Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 ...
分类:
编程语言 时间:
2020-06-01 12:03:41
阅读次数:
72
给定一个矩阵,矩阵中的元素表示成本,求,从矩阵左上角到右下角最小的成本路线,每一次只能向右或者向下走。 Input:[ [1,3,1], [1,5,1], [4,2,1]]Output: 7Explanation: Because the path 1→3→1→1→1 minimizes the s ...
分类:
其他好文 时间:
2020-05-31 17:45:01
阅读次数:
54
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], ...
分类:
其他好文 时间:
2020-05-31 13:17:49
阅读次数:
57
问题: 给定数组, 假定反转动作k,表示:将数组前k个元素进行反转。 求反转动作k的序列,使得数组最终成为一个递增数组。(特:该数组为1~A.size()的一个排序) Example 1: Input: [3,2,4,1] Output: [4,2,4,3] Explanation: We perf ...
分类:
其他好文 时间:
2020-05-30 10:28:57
阅读次数:
55
问题: 给定数组,求一对 index为 ( i , j ) 的 A[i] <= A[j] && i < j,两个index距离最远。(即max(j-i)) Example 1: Input: [6,0,8,2,1,5] Output: 4 Explanation: The maximum width ...
分类:
其他好文 时间:
2020-05-29 15:12:28
阅读次数:
66