Team Formation Problem Statement

You will be provided with an array/list 'ARR' consisting of 'N' positive integers representing runs scored by 'N' top players in their last innings. An integer 'X' is also given as a target. You scored only 30 runs and gave the rest of the target runs to two other players from the list. Your task is to identify two players such that the combined runs they scored in their last innings are less than or equal to 'X - 30'.

Input:

ARR = [30, 40, 10, 8, 60, 100, 40], X = 110

Output:

[40, 40]

Example:

Given the 'ARR': [30, 40, 10, 8, 60, 100, 40] and 'X' = 110, possible output pairs could be [30, 40], [40, 40], or [40, 10]. The pair with the highest run total, [40, 40], should be returned.

Constraints:

  • There will always be a pair with a sum less than or equal to 'X - 30'.
  • In the pair, the second integer must be larger than the first integer.
  • 1 <= T <= 5
  • 1 <= N <= 105
  • 0 <= A[i], X <= 109
  • Time Limit: 1 sec

Note:

No need to print anything; it is already handled.

Be the first one to answer
Select
Add answer anonymously...
Infineon Technologies Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits