Handle edge case of sgn(x) != sgn(y)

This commit is contained in:
2017-12-11 12:13:20 +01:00
parent 237e1014ac
commit 817ef2dcfb

View File

@@ -32,6 +32,10 @@ object solution {
}
def dist(x: Int, y: Int): Int = {
return Math.max(x, y);
if (x.signum == y.signum) {
return Math.max(x.abs, y.abs);
} else {
return x.abs + y.abs
}
}
}