Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean what(int[] a, int num)
- {
- int start = 0;
- int sum = a[0];
- int end = 1;
- while(start < a.length){
- if(sum == num)
- return true;
- else if(sum > num){
- sum -= a[start];
- start++;
- }
- else if(end < a.length){
- sum += a[end];
- end++;
- }
- else
- return false;
- }
- return sum == num;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement