Java: Two Elements whose Sum is Closest to Zero

Level : Intermediate
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:30:00

Lab Details

Difficulty Level: MEDIUM

Problem Statement:

An Array of integers is given, both +ve and -ve. You need to find the two elements such that their sum is closest to zero.

Input:

arr[] = {1, 80, -10, 70, -60, 65}

Output:

The two elements whose sum is minimum are -80 and 85


Self-paced Membership
  • 22+ Courses
  • 750+ Hands-On Labs
  • 200+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A
  • 10+ Real-world Projects
  • Career Coaching
  • Email Support
Upto 66% OFF
KNOW MORE..

To get full access to all courses

Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this