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
Add answer anonymously...
Infineon Technologies Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter