Quote:Original post by MOVSW
My coworker is sort of an asshat, i bet this algorithm is probably not even optimizable to O(n).
How can you bet that if someone has ALREADY explained how to do it in O(n) in this very thread?
Quote:Original post by MOVSW
My coworker is sort of an asshat, i bet this algorithm is probably not even optimizable to O(n).
bool bDone = false;int ai=0, bi=0, ci=0;while(!bDone){ if(a[ai] == b[bi] && b[bi] == c[ci]) break; else { if(a[ai] <= b[bi] && a[ai] <= c[ci]) ai++; else if(b[bi] <= a[ai] && b[bi] <= c[ci]) bi++; else if(c[ci] <= a[ai] && c[ci] <= b[bi]) ci++; if(ai, bi, or ci went out of bounds) bDone = true; }}if(!bDone) cout << "Match found";