Swift Solution:
public func solution(X : Int, _ Y : Int, _ D : Int) -> Int {
// Make sure the Destination is far than start point
if (Y - X <= 0) { return 0 }
var steps = (Y - X) / D
if ((Y - X) % D) > 0 { steps += 1 }
return steps
}
网友评论