Report Where a Value Appears

Last updated: July 5, 2026

Quick Overview

Write a function that takes an array and a target value, returning the indices of the array where the target value appears.

Upstart
Coding & Algorithms
Software Engineer
Upstart
July 5, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

2

0

23 solved


Write a function that takes an array and a target value, returning the indices of the array where the target value appears.

This question is typically asked during the online assessment round for software engineering candidates at Upstart. The interviewer is evaluating the candidate's ability to implement basic algorithms and handle array manipulations efficiently. It tests both problem-solving skills and coding proficiency in a straightforward scenario.

What the Interviewer Expects
  • Correctly identifies all indices of the target value in the array.
  • Demonstrates a clear understanding of array traversal techniques.
  • Handles edge cases, such as an empty array or a target value not present.
  • Optimizes for time and space complexity where applicable.
  • Provides clean, readable, and well-documented code.
Key Topics to Cover
Array manipulation
Searching algorithms
Time complexity
Edge cases
Code readability
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you modify your solution to handle large datasets?
  • Can you explain the time and space complexity of your approach?
  • What would you do if the array were sorted?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Approach

To solve the problem, I will iterate through the array and check each element to see if it matches the target value. If a match is found, I will store the index in a list that will be returned at the ...

Algorithm

The algorithm can be implemented in a single pass through the array. Here is the Python code for the solution:

def find_indices(arr, target): indices = [] for index, value in enumer...

Submit Your Answer
Markdown supported

Related Questions