Advertisement
nikunjsoni

1822

Apr 12th, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int arraySign(vector<int>& nums) {
  4.         int  res = 1;
  5.         for(int x: nums){
  6.             if(x)
  7.                 x = (x>0)? 1 : -1;
  8.             res = res * x;
  9.         }
  10.         return res;
  11.     }
  12. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement