• + 5 comments

    By the definition of the problem, x1 is always less than x2 - so no need to test for that in your first if statement. Otherwise it looks good.