Swift💯
Good Interview Answer (accepted answer)\n\nThis is good interview answer because:\n1) It is simple, clear and concise. (One pass through the array, not a fancy 
**Good Interview Answer (accepted answer)**\n\nThis is good interview answer because:\n1) It is simple, clear and concise. (One pass through the array, not a fancy sort + binary search, etc..)\n2) Doesn\'t use Multiplication (in theory faster)\n3) Doesn\'t use `.reduce()`, so can short-circuit at the first zero (faster).\n\nNote: Problem doesn\'t state what to return for an empty array. Given constraints state that the array always has more than one element, but this would be a good followup with your interviewer to ask to remove the constraint and handle accordingly (return zero, throw, etc).\n\n```\nclass Solution {\n    func arraySign(_ nums: [Int]) -> Int {\n        var result = 1\n        for num in nums where num < 1 {\n            guard num != 0 else { return 0 }\n            result = -result\n        }\n        return result\n    }\n}\n```\n\n---\n\n**One-Liner, terse (accepted answer)**\nNot for interviews.\n```\nclass Solution {\n    func arraySign(_ nums: [Int]) -> Int {\n        nums.lazy.map{$0.signum()}.reduce(1,*)\n    }\n}\n```
['Swift']