auto commit

This commit is contained in:
CyC2018 2018-03-12 11:07:26 +08:00
parent 96574fa09c
commit ce2518d2af

View File

@ -1396,10 +1396,11 @@ public Double GetMedian() {
请实现一个函数用来找出字符流中第一个只出现一次的字符。例如,当从字符流中只读出前两个字符 "go" 时,第一个只出现一次的字符是 "g"。当从该字符流中读出前六个字符“google" 时,第一个只出现一次的字符是 "l"。
```java
//Insert one char from stringstream
public class Solution {
private int[] cnts = new int[256];
private Queue<Character> queue = new LinkedList<>();
//Insert one char from stringstream
public void Insert(char ch) {
cnts[ch]++;
queue.add(ch);
@ -1413,6 +1414,7 @@ public char FirstAppearingOnce() {
if (queue.isEmpty()) return '#';
return queue.peek();
}
}
```
## 42. 连续子数组的最大和
@ -1422,11 +1424,11 @@ public char FirstAppearingOnce() {
{6,-3,-2,7,-15,1,2,2},连续子向量的最大和为 8从第 0 个开始,到第 3 个为止)
```java
public int FindGreatestSumOfSubArray(int[] array) {
if(array.length == 0) return 0;
public int FindGreatestSumOfSubArray(int[] nums) {
if (nums.length == 0) return 0;
int ret = Integer.MIN_VALUE;
int sum = 0;
for(int num : array) {
for (int num : nums) {
if (sum <= 0) sum = num;
else sum += num;
ret = Math.max(ret, sum);