Practice Sign of the Product of an Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Return the sign of the product of all values in nums: 1 for a positive product, -1 for a negative product, and 0 for a zero product.
Source: Sign of the Product of an Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [-1,-2,-3,-4,3,2,1]
Output
1
# Example 2
Input
nums = [1,5,0,2,-3]
Output
0
# Example 3
Input
nums = [-1,1,-1,1,-1]
Output
-1
Constraints
1 <= nums.length <= 1000
-100 <= nums[i] <= 100
Related LeetCode Problems
Practice more problems similar to Sign of the Product of an Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.