Algorithm to calculate number of intersecting discs

前端 未结 30 1498
鱼传尺愫
鱼传尺愫 2020-12-12 10:57

Given an array A of N integers we draw N discs in a 2D plane, such that i-th disc has center in (0,i) and a radius

30条回答
  •  执念已碎
    2020-12-12 11:42

    Swift 4 Solution 100% (Codility do not check the worst case for this solution)

    public func solution(_ A : inout [Int]) -> Int {
        // write your code in Swift 4.2.1 (Linux)
        var count = 0
        let sortedA = A.sorted(by: >)
        if sortedA.isEmpty{ return 0 }
        let maxVal = sortedA[0]
    
        for i in 0.. 10_000_000{
                return -1
            }
        }
    
        return count
    }
    

提交回复
热议问题