Practice Largest Positive Integer That Exists With Its Negative
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Easy#2441
LeetCode ProblemLargest Positive Integer That Exists With Its Negative
Problem Statement
Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array. Return the positive integer k. If there is no such integer, return -1.
Source: Largest Positive Integer That Exists With Its Negative on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [-1,2,-3,3]
Output
3
# Example 2
Input
nums = [-1,10,6,7,-7,1]
Output
7
# Example 3
Input
nums = [-10,8,6,7,-2,-3]
Output
-1
Constraints
1 <= nums.length <= 1000
-1000 <= nums[i] <= 1000
nums[i] != 0
Related LeetCode Problems
Practice more problems similar to Largest Positive Integer That Exists With Its Negative.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.