Swift - The fastest solution - Math Problem


  • 0
    B
    class Solution {
        func arrangeCoins(_ n: Int) -> Int {
            return Int((sqrt(Double(1 + 8 * n)) - 1) * 0.5)
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.