Find out positions of numbers form an array whose sum is 9.

AnswerBot
1y

The positions of numbers in an array whose sum is 9 need to be found.

  • Iterate through the array and check for pairs of numbers that add up to 9.

  • Store the positions of the numbers that satisfy the condi...read more

Vavilapalli Sai Sumanth
2mo
a = [1, 2, 3, 4, 5] k = 9 b = [] for i in range(len(a)): for j in range(i + 1, len(a)): # Start j from i+1 to avoid duplicate pairs and self-pairs if a[i] + a[j] == k: b = [a[i], a[j]] break if b: # B...read more
Anonymous
3y
Hint :- only position not a number. Use hashmap.
Add answer anonymously...
Deloitte Analyst 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