Tap here to switch tabs
Problem
Submissions

Problem: Largest Positive Integer That Exists With Its Negative

Largest Positive Integer That Exists With Its Negative asks you to find the greatest positive value in an array of nonzero integers whose negative also appears, or return -1 if none does.

Statement

Given an integer array nums that does not contain any zeros, find the largest positive integer k such that its negation also exists in the array.

Return the value of k. If no such integer exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • −1000≤-1000 \leq nums[i] ≤1000\leq 1000

  • nums[i] ≠0\neq 0

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Largest Positive Integer That Exists With Its Negative

Largest Positive Integer That Exists With Its Negative asks you to find the greatest positive value in an array of nonzero integers whose negative also appears, or return -1 if none does.

Statement

Given an integer array nums that does not contain any zeros, find the largest positive integer k such that its negation also exists in the array.

Return the value of k. If no such integer exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • −1000≤-1000 \leq nums[i] ≤1000\leq 1000

  • nums[i] ≠0\neq 0