[Codility] Lession 3.2 FrogJmp

作者: sunlitamo | 来源:发表于2016-07-21 22:43 被阅读38次

    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
    
    }
    

    相关文章

      网友评论

        本文标题:[Codility] Lession 3.2 FrogJmp

        本文链接:https://www.haomeiwen.com/subject/xjzbjttx.html