Product exclusions
Medium · Arrays & hashing · Original CodeClash problem
Input is an integer array. Return the product of every other element for each position. Empty input returns []. Do not use division.
Input and output
One JSON value on a single line, with the fields described above. Read it using json.loads(input()).
One compact JSON value. Use print(json.dumps(answer, separators=(",", ":"))). Booleans must be JSON true/false. Arrays retain the stated order.
Examples
Example 1
Input: [1,2,1] Output: [2,1,2]
Example 2
Input: [3,2,1] Output: [2,3,6]
Constraints
- Array and string lengths are at most 200 unless stated otherwise.
- Integers have absolute value at most 10,000 unless stated otherwise.
- All inputs satisfy the stated preconditions.
Sign in to save progress. Public example runs are unverified and do not affect ratings.