add comments for solution of O(log(M+N))