1822. Sign of the Product of an Array 發表於 2023-02-13 | 分類於 leetcode problemsolution123456789101112class Solution {public: int arraySign(vector<int>& nums) { int ret = 1; for(int n:nums){ // avoid overflow if(n<0) ret*=(-1); else if(n==0) return 0; } return ret<0?-1:1; }};