-
Notifications
You must be signed in to change notification settings - Fork 266
Expand file tree
/
Copy path61.java
More file actions
54 lines (31 loc) · 803 Bytes
/
61.java
File metadata and controls
54 lines (31 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Solution {
public int[][] findContinuousSequence(int target) {
List<int[]> list = new ArrayList<>();
int left = 1,right = 2;
int sum = 3;
while(right<target)
{
if(sum<target)
{
right++;
sum+=right;
}
else if(sum>target)
{
sum-=left;
left++;
}
else{
int nums[] = new int[right-left+1];
for(int i=0;i<=right-left;i++)
{
nums[i] = left+i;
}
list.add(nums);
right++;
sum+=right;
}
}
return list.toArray(new int[0][]);
}
}