Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2441. Largest Positive Integer That Exists With Its Negative #51

Open
F4NT0 opened this issue May 4, 2024 · 0 comments
Open

2441. Largest Positive Integer That Exists With Its Negative #51

F4NT0 opened this issue May 4, 2024 · 0 comments
Assignees
Labels
Easy Easy Questions Ready to code Description from the Question was updated with code and text
Milestone

Comments

@F4NT0
Copy link
Owner

F4NT0 commented May 4, 2024

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.

Example 1:

  • Input: nums = [-1,2,-3,3]
  • Output: 3
  • Explanation: 3 is the only valid k we can find in the array.

Example 2:

  • Input: nums = [-1,10,6,7,-7,1]
  • Output: 7
  • Explanation: Both 1 and 7 have their corresponding negative values in the array. 7 has a larger value.

Example 3:

  • Input: nums = [-10,8,6,7,-2,-3]
  • Output: -1
  • Explanation: There is no a single valid k, we return -1.

Constraints:

  • 1 <= nums.length <= 1000
  • -1000 <= nums[i] <= 1000
  • nums[i] != 0
@F4NT0 F4NT0 added Easy Easy Questions Ready to code Description from the Question was updated with code and text labels May 4, 2024
@F4NT0 F4NT0 added this to the May LeetCode milestone May 4, 2024
@F4NT0 F4NT0 self-assigned this May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy Easy Questions Ready to code Description from the Question was updated with code and text
Projects
None yet
Development

No branches or pull requests

1 participant