Given a non-decreasing array, how can I determine the indices of an element X within it? If the element is not present, the output should be [-1, -1]. For example, for the array [1,2,3,3,5,5,7,8] and X=5, the expected output is [4,5], as the element 5 is found at the 4th and 5th indices.

AnswerBot
18h

Find indices of an element in a non-decreasing array

  • Iterate through the array and keep track of the indices where the element X is found

  • Return the list of indices or [-1, -1] if element X is not found...read more

Help your peers!
Add answer anonymously...
Sigmoid Senior Data 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