Thomash のアルゴリズムは を 2 回呼び出しintersectて中間リストを作成するので、効率的ではありません。
あなたのアルゴリズムは本質的に正しいです。余分なビットは、2 つの頭が最大に等しい場合があり、残りの頭だけをドロップする必要があることです。
OCaml で書かれた改訂されたアルゴリズムは次のとおりです。
let rec intersect xs ys zs =
match xs, ys, zs with
| [], _, _ | _, [], _ | _, _, [] -> None
| x::xs', y::ys', z::zs' ->
if x = y && y = z then Some x
else
let m = max x (max y z) in
if x = m && y = m then intersect xs ys zs'
else if x = m && z = m then intersect xs ys' zs
else if y = m && z = m then intersect xs' ys zs
else if x = m then intersect xs ys' zs'
else if y = m then intersect xs' ys zs'
else intersect xs' ys' zs