Golang, with more than a few conversions between types


  • 0
    R
    import "math"
    
    func constructRectangle(area int) []int {
        w := int(math.Sqrt(float64(area)))
        for int(area) % w != 0 {w-- }
        return []int{(int(area)/w), w}
    }
    

Log in to reply
 

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