MaxProductOfThree

import Foundation

import Glibc

// you can write to stdout for debugging purposes, e.g.

// print("this is a debug message")

public func solution(_ A : inout [Int]) -> Int {

    // write your code in Swift 4.2.1 (Linux)



    let max : Int

    let min : Int


    A.sort()


    max = A[A.count - 1] * A[A.count - 2] * A[A.count - 3]


    min = A[0] * A[1] * A[2]


    return max > min ? max : min

}

你可能感兴趣的:(MaxProductOfThree)