[swift-users] Compile time exceeded. Anything wrong?

Hbucius Smith hbucius at gmail.com
Mon Jun 5 07:32:18 CDT 2017


Hi Swift-Users,

    when I compiled the code, Xcode cannot stop, I do not know why. It is
very strange. Can anyone help ? Here is the code. I am using Xcode 8.1

class Solution {

    func rob(nums: [Int]) -> Int {

        guard nums.count > 0 else { return 0 }

        let dp = Array.init(repeating: Array.init(repeating: 0, count:
nums.count),

                            count: 2)

        dp[0][0] = 0

        dp[0][1] = nums[0]

        for i in 1 ..< nums.count {

            dp[i][0] = max(dp[i - 1][0], dp[i - 1][1])

            dp[i][1] = dp[i - 1][0] + nums[i]

        }

        return 0

    }

}



*best wishes for you *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170605/c7130b1e/attachment.html>


More information about the swift-users mailing list