Skip to content

Commit 1605c5c

Browse files
committed
算法聚集
1 parent 22221ee commit 1605c5c

10 files changed

+55
-22
lines changed

MD/在线编程-奇偶链表排序.md

Lines changed: 0 additions & 14 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
https://leetcode.com/problems/container-with-most-water/
2+
3+
给出一个非负整数数组,每一个整数表示一个竖立在坐标轴x位置的一堵高度为该整数的墙,选择两堵墙,和x轴构成的容器可以容纳最多的水
4+
5+
```java
6+
class Solution {
7+
public int maxArea(int[] height) {
8+
int i = 0, j = height.length - 1;
9+
int max = 0;
10+
while(i < j){
11+
max = Math.max(max, Math.min(height[i], height[j])*(j-i));
12+
if(height[i] < height[j]){
13+
i++;
14+
}else{
15+
j--;
16+
}
17+
}
18+
return max;
19+
}
20+
}
21+
```
File renamed without changes.
File renamed without changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
https://leetcode.com/problems/minimum-size-subarray-sum/
2+
3+
给定一个整形数组和一个数字s,找到数组中最短的一个连续子数组,使得连续子数组的数字和sum>=s,返回这个最短的连续子数组的长度值
4+
5+
```java
6+
class Solution {
7+
public int minSubArrayLen(int s, int[] nums) {
8+
int i = 0, j = -1, sum = 0, minLength = Integer.MAX_VALUE;
9+
while(i < nums.length){
10+
if(j + 1 < nums.length && sum < s){
11+
sum+=nums[++j];
12+
}else{
13+
sum-=nums[i++];
14+
}
15+
if(sum >= s){
16+
minLength = Math.min(j-i+1, minLength);
17+
}
18+
}
19+
if(minLength == Integer.MAX_VALUE){
20+
return 0;
21+
}
22+
return minLength;
23+
}
24+
}
25+
```
File renamed without changes.

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ PS:除开知识点,一定要准备好以下套路:
4343
* [API网关原理](http://www.wangtianyi.top/blog/2017/04/22/yi-microservies-2-building-microservices-using-an-api-gateway/)
4444
* [服务配置中心](http://sjyuan.cc/service-config-server/)
4545
* [服务容错保护](http://sjyuan.cc/service-fault-tolerant-protected-with-hytrix/)
46-
### 在线编程
47-
* [二叉树-二叉树反转](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/在线编程-二叉树反转.md)
48-
* [链表-链表相加](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/在线编程-链表相加.md)
49-
* [链表-奇偶链表排序](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/在线编程-奇偶链表排序.md)
50-
* [数组-合并有序数组](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/在线编程-合并有序数组.md)
51-
* [数组-第k大个数](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/在线编程-第k大个数.md)
52-
* [动态规划-连续子数组最大和](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/在线编程-连续子数组最大和.md)
53-
* [数据结构-LRU淘汰算法](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/在线编程-LRU淘汰算法.md)
46+
### 算法
47+
* [数组-快速排序-第k大个数](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/算法-数组-快速排序-第k大个数.md)
48+
* [数组-对撞指针-最大蓄水](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/算法-数组-对撞指针-最大蓄水.md)
49+
* [数组-滑动窗口-最小连续子数组](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/算法-数组-滑动窗口-最小连续子数组.md)
50+
* [数组-归并排序-合并有序数组](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/算法-数组-归并排序-合并有序数组.md)
51+
* [链表-链表反转-链表相加](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/算法-链表-反转链表-链表相加.md)
52+
* [二叉树-二叉树反转](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/算法-二叉树-二叉树反转.md)
53+
* [动态规划-连续子数组最大和](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/算法-动态规划-连续子数组最大和.md)
54+
* [数据结构-LRU淘汰算法](https://github.com/xbox1994/2018-Java-Interview/blob/master/MD/算法-数据结构-LRU淘汰算法.md)
5455
### 问题排查
5556
* [Java生产环境下问题排查](http://www.wangtianyi.top/blog/2018/07/20/javasheng-chan-huan-jing-xia-wen-ti-pai-cha/)
5657
### 项目举例

0 commit comments

Comments
 (0)