Skip to content

Commit 8652342

Browse files
committed
disc07
1 parent 26bceac commit 8652342

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class finsum{
2+
public static boolean findSumFaster(int[] A, int x){
3+
int left = 0;
4+
int right = A.length - 1;
5+
while (left <= right) {
6+
if (A[left] + A[right] == x) {
7+
return true;
8+
} else if (A[left] + A[right] < x) {
9+
left++;
10+
} else {
11+
right--;
12+
}
13+
}
14+
return false;
15+
}
16+
}

0 commit comments

Comments
 (0)