LoginSignup
0
0

More than 5 years have passed since last update.

CodilityのTrainingを解いてみた その4

Posted at

問題 PermMissingElem

  • 使用言語:Swift3

ソースコード

public func solution3_1(_ A : inout [Int]) -> Int {
        if A.count == 0 {
            return 1
        }

        var allSum = 0
        var luckSum = 0
        for i in 0...A.count {
            if i <= A.count - 1 {
                luckSum = luckSum + A[i]
            }
            allSum = allSum + i + 1
        }
        return allSum - luckSum
    }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0