欢迎使用CSDN-markdown编辑器

来源:互联网 发布:简明python教程电子书 编辑:程序博客网 时间:2024/06/01 08:53

给定一个整数数组,找到和为零的子数组。你的代码应该返回满足要求的子数组的起始位置和结束位置
您在真实的面试中是否遇到过这个题?
样例

给出 [-3, 1, 2, -3, 4],返回[0, 2] 或者 [1, 3].
标签
相关题目

public class Solution {
/**
* @param nums: A list of integers
* @return: A list of integers includes the index of the first number
* and the index of the last number
*/
public ArrayList subarraySum(int[] nums) {
if(nums == null || nums.length <1) return null;
int len = nums.length;
int start = 0;
int end = len;
int[] sums = new int[len+1];
for(int i=0;i

0 0