use reduce and cmp.