You are viewing a single comment's thread. Return to all comments →
I am also using same logic but it gives me WA, please have a look s1,s2,s3 are sum of array for each array
static int equalStacks(int[] h1, int[] h2, int[] h3,long s1,long s2,long s3) { int i=0,j=0,k=0; int l=h1.length; int m=h2.length; int n=h3.length; while(i<l && j<m && k<n) { if(s1==s2 && s2==s3) return (int)s1; if(s1>Math.max(s2,s3)) s1-=h1[i++]; else if(s2>Math.max(s1,s3)) s2-=h2[j++]; else s3-=h3[k++]; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Equal Stacks
You are viewing a single comment's thread. Return to all comments →
I am also using same logic but it gives me WA, please have a look s1,s2,s3 are sum of array for each array