You are viewing a single comment's thread. Return to all comments →
Since the arrays are in sorted form, you could use that in finding the highest common number. It takes lesser time and will pass all the test cases.
int i,j,k; i = n1-1; j = n2-1; k = n3-1; while(i>=0 && j>=0 && k>=0){ if(h1[i]==h2[j] && h2[j]==h3[k]){ printf("%d",h1[i]); return 0; } while(h1[i]>h2[j] || h1[i]>h3[k]){ i--; } while(h2[j]>h1[i] || h2[j]>h3[k]){ j--; } while(h3[k]>h2[j] || h3[k]>h1[i]){ k--; } } printf("0"); 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 →
Since the arrays are in sorted form, you could use that in finding the highest common number. It takes lesser time and will pass all the test cases.