Sign of the Product of an Array Problem

Sign of the Product of an Array Problem — ExecCode Easy DSA Practice

Solve the Sign of the Product of an Array problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an integer array nums. Your task is to compute the required answer and return signFunc(product). Implement a function signFunc(x) that returns: - 1 if x is positive. - -1 if x is negative. - 0 if x is equal to 0.

Examples

Input {"nums": [-1, -2, -3, -4, 3, 2, 1]}; Output 1. Input {"nums": [1, 5, 0, 2, -3]}; Output 0

Constraints

1 <= nums.length <= 1000 -100 <= nums[i] <= 100

Practice Sign of the Product of an Array free on ExecCode. Browse DSA problems, topic map, and placement guides.