← 返回博客列表
Amazon

Amazon Intern OA (HackerRank, 70 mins) Recap: First Unique Character + Distinct Target Pairs

2026-04-14

Amazon Intern OA HackerRank screenshot Q1

This was an Amazon Intern OA on HackerRank with a 70-minute limit. Both questions were fundamental, but clean handling of details mattered.


Q1: Return the index of the first unique character

Interview-ready wording

I solve it in two passes:

  1. First pass: count frequency of each character (HashMap or fixed array).
  2. Second pass: scan in original order and return the first index whose frequency is exactly 1.

If none exists, return the fallback required by the statement (commonly -1).

Complexity


Q2: Count distinct pairs whose sum equals target

Amazon Intern OA HackerRank screenshot Q2

Interview-ready wording

For each number x:

At the end, the number of distinct stored smaller values equals the number of distinct valid pairs.

This works well because the same numeric pair (e.g., 2 and 7) always maps to the same dedup key (2) regardless of encounter order.

Complexity


Common mistakes under time pressure


One-line takeaway

This OA set is less about advanced algorithms and more about stable basics, clean edge handling, and clear dedup logic.


If you are preparing for Amazon Intern OA (HackerRank), feel free to reach out for similar high-frequency variants and explanation templates.


Further Reading (External Links)


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

Contact

Email: [email protected]
Telegram: @OAVOProxy