← 返回博客列表
Uber

Uber OA (HackerRank) Recap 2026: Monotonic Stack Discounts + Union-Find Components

2026-04-14

Uber OA HackerRank screenshot Q1

This Uber OA was taken on HackerRank. The two questions are standard patterns, but both require clean implementation under time pressure.


Q1: Price Discount with Monotonic Stack

Core idea

Use a monotonic stack and iterate from right to left:

Then maintain three outputs required by the statement:

Return total and full-price indices based on the problem format.

Complexity


Q2: Connectivity Time / Number of Components (Union-Find)

Uber OA HackerRank screenshot Q2

Essence

This is a connected-components problem. Use Union-Find directly.

Group-and-merge method

Group points by x and by y:

Then sort and merge in both dimensions:

Finally, count distinct roots (number of disconnected components), then convert to the asked time/result format.

Complexity

Let n be number of points:


Common mistakes in interview


One-line takeaway

Q1 is a classic monotonic-stack template; Q2 is grouping + sorting + Union-Find. Keep state updates clean and this set is very manageable.


If you are not fully confident about Uber OA, support is available. You can also ask about other companies.

#uber #internationalstudents #newgrad #internship #jobsearch #hackerrank #interviewrecap


Further Reading (External Links)


Need real interview questions? Contact WeChat Coding0201: Get Questions.

Contact

Email: [email protected]
Telegram: @OAVOProxy