signFunc(x) returns 1 when x is positive, -1 when x is negative and 0 when x is 0. Given an integer array nums, let product be the product of all its values, and return signFunc(product).
signFunc(x) returns 1 when x is positive, -1 when x is negative and 0 when x is 0. Given an integer array nums, let product be the product of all its values, and return signFunc(product).
Example 1:
Input: {"nums":[-1,-2,-3,-4,3,2,1]}
Output: 1
Constraints:
1≤nums.length≤1000
−100≤nums[i]≤100
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[-1,-2,-3,-4,3,2,1]}
The real product of 7 numbers can be enormous, so track only its sign.