Panda Guru LogoPanda
Guru

Salesforce OA || 6 oct

Round 1

Questions: There are n towers placed sequentially in the city of Hackerland. Tower x is visible from tower y if all towers between x and y have a height strictly less than that of x. For each tower, find the number of towers visible from this tower, both on the left and right side.

Example:

There are n = 4 towers and height = [5, 2, 10, 1].

Return (2, 2, 3, 1).

Candidate's Approach

The candidate attempted a brute force approach which was able to pass 9 out of 15 test cases. They were trying to implement a stack-based approach to count the visible towers on both the left and right sides but encountered issues with some edge cases.

Interviewer's Feedback

No feedback provided.