Advertisement
naorzr

Untitled

Mar 2nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.27 KB | None | 0 0
  1. public static boolean contingiousSub(int [] a,int num){
  2.           int sum = 0,start=0;
  3.           for(int k=0;k<a.length;k++){
  4.               sum+= a[k];
  5.               while(sum>num){
  6.                   sum-=a[start];
  7.                   start++;
  8.               }
  9.               if(sum==num)
  10.                   return true;
  11.           }
  12.           return false;
  13.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement