lg(m+n) solution

throw away a part from each array every step, but too many explicit branch on edge cases