HRT OA 面經分享|三道經典 Coding 真題解析

1,178Views
尚無留言

說實話, HRT OA 難度不算「入門級」,但是整體風格還是挺清晰的,主要考察的是 邏輯推理 + 高效實現能力,題目更偏向「思維敏捷」和「代碼簡潔度」。。 我當時準備的時候發現,和一些傳統大廠不同,HRT 特別喜歡那種 corner case 很多但核心思路其實不複雜 的題目。 下面整理一下三道真題給大家參考。

Question 1 of 3

A positive integer is “fancy” if its representation in base 4 only includes 0s and 1s. For example:

  • 17 is fancy: its base – 4 representation, 101, only includes 0s and 1s.
  • 18 is not fancy: its base – 4 representation, 102, includes a 2.

Given a positive integer n, find the number of fancy positive integers less than n.

Example:

  • For n = 1, the output should be 0: there are no positive integers less than 1.
  • For n = 10, the output should be 3, since {1, 4, 5} are all fancy.

Constraints:

  • 0 < n ≤ 10⁹
  • [execution time limit] 0.5 seconds (cpp)

Question 2 of 3

Tiles must be identical to combine. If three tiles combine, only the two farthest in the direction of motion combine. For example, if this board moves right:
2,2,2
the following board results:
...,2,4

If four tiles are in a row or column, a move parallel to that row or column combines the first two and the last two (e.g. 2,2,2,2 -> 4,4). Also, the result of two tiles combining cannot collide again in the same turn.

Once the move is complete, a new value is placed at a provided X and Y coordinate. The new value must be placed after the movement for that round is complete.

You will receive a list of moves formatted as strings. Each move will be in the following format:
Direction X Y Value

Example Input
["U 0 0 2", "U 1 0 2", "L 3 3 4"]

Example Output
"4,,,,\n,,,,\n,,,,\n,,,,4"

Constraints:

  • Board is 4×4
  • Direction = {U, D, L, R}
  • Coordinates are zero-indexed
  • [execution time limit] 0.5 seconds (cpp)

Question 3 of 3

You are given a grid with n rows and m columns, initially empty. A sequence of operations will be performed on this grid:

  • "Row r v" → add value v to all cells in row r
  • "Col c v" → add value v to all cells in column c

After processing all operations, you need to return the maximum value present in the grid.

Example Input

n = 3, m = 3
operations = ["Row 1 3", "Col 0 2", "Row 2 1"]

Example Output

5

Constraints:

  • 1 ≤ n, m ≤ 10⁵
  • 1 ≤ number of operations ≤ 10⁵
  • Values can be up to 10⁹
  • [execution time limit] 0.5 seconds (cpp)

總結

HRT 的 OA 題整體有兩個特點:

  1. 複雜度要求比較苛刻,幾乎每道題都需要在 O(log n) 或 O(n) 級別搞定,暴力解法直接超時。
  2. 類比+細節處理很考驗心態,比如第二題那種 tile merge,邏輯沒寫全就容易掛 case。

如果准备 HRT 的同学,建议多刷一些 构造类、数位 DP、模拟大模拟 的题,心态放稳,写干净代码就行。

👉 最後,如果你覺得類似 OA/VO 壓力大,或者在 coding 過程中經常卡住,Programhelp 可以提供遠端語音提醒、即時 OA 助攻,讓你保持思路清晰,不會卡在 tricky 的細節上。 有學員就是靠著這種小助攻順利通過 HRT OA,後面還拿到 onsite。

author avatar
jor jor
END
 0
Comment(尚無留言)