Write a program: two input, one is N(any integer, lets say 3), second input will be array of integers(duplicate/multiple occurrences of same integer, lets say [2,3,2,4,2] ). You have to return the number whose occurrence is greater than N/2. If found nothing return '-1' . In this example you have to return "2" as N/2 is "1.5" and number "2" has 3(3 is > 1.5) occurrence in the array.

AnswerBot
1y

Program to find the number whose occurrence is greater than N/2 in an array of integers.

  • Take two inputs, one integer N and an array of integers.

  • Loop through the array and count the occurrence of each ...read more

Help your peers!
Add answer anonymously...
Nagarro Senior Engineer 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
Get AmbitionBox app

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