← GE HealthCare Interview Insights

GE HealthCare·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Interviewed for a Software Engineer role at GE HealthCare and got a monotonic stack problem that I'd seen before but still fumbled the edge cases under pressure.

Questions Asked (1)

Q1

Given an array of heights representing people standing in a line, for each person determine how many people to their right they can see. A person can see another if everyone standing between them is shorter than both of them.

Algorithms & Data Structures
Author's notes

I knew a stack was involved but spent too long trying to build it left-to-right before realizing scanning from the right makes way more sense.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a monotonic decreasing stack to efficiently compute visible people to the right. Iterate from right to left, maintaining a stack of indices with heights in decreasing order. For each person, pop shorter or equal heights, count the remaining stack elements (those visible), then push the current index.

Pro tip: Clarify the visibility condition: a person can see another if all between are strictly shorter than both. This means equal heights block visibility. Mentioning this shows attention to detail and avoids off-by-one errors.

1. Understand the problem

Restate the visibility condition: person i can see person j (i < j) if all k between i and j have height < min(height[i], height[j]). Note that equal heights block visibility.

2. Choose the right data structure

Use a monotonic decreasing stack to keep track of people to the right that are visible. The stack stores indices, and heights are strictly decreasing from bottom to top.

3. Iterate from right to left

Process each person from rightmost to leftmost. For each person, pop from the stack while the stack is not empty and the height at the top is <= current height. The remaining stack size is the number of visible people to the right.

4. Update the stack and record result

After counting, push the current index onto the stack. Store the count in an output array at the current index.

5. Analyze complexity and edge cases

Time complexity is O(n) because each element is pushed and popped at most once. Space complexity is O(n) for the stack. Handle edge cases like empty array, single element, and all equal heights.

Key Points to Mention

  • Monotonic stack (decreasing) for O(n) time complexity
  • Iterating from right to left to leverage already computed information
  • Strict inequality: equal heights block visibility, so pop when height <= current
  • The stack size after popping gives the number of visible people
  • Time and space complexity analysis: O(n) time, O(n) space
  • Edge cases: empty array, single person, all equal heights, strictly increasing/decreasing heights

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.