這次陪審員過 Palantir OA ,整體感覺是:題目本身不算偏,但邏輯密度很高,時間又壓得緊
稍微想偏一點點,整題就容易爆掉。學員本身基礎不錯,但做題容易緊張、遇到組合類題目步子會亂,所以這次他是直接開了 Programhelp 的 OA 無痕聯機助攻服務。
我們在獨立乾淨的環境裡同步看題、同步寫,不會留下任何操作痕跡,對這種邏輯題強、限時強的 OA 來說非常友善。
以下依序複盤三題,並講講在關鍵點上是怎麼透過助攻穩住節奏的。
1. No Pairs Allowed
For each word in a list of words, if any two adjacent characters are equal, change one of them. Determine the minimal number of such substitutions so that thefinal string has no adjacent equal characters.
Exampl
words = [“seed”, “baalll”, “stone”]
"seed"→ the two e’s are adjacent → 1 change"baalll"→ there are two pairs (“aa”, “ll”) → 2 changes"stone"→ no adjacent duplicates → 0 changes
Return: [1, 2, 0]
Function Description
Complete the function minimalOperations.
Parameters:
- string words[m]
Returns: - int[m]
Constraints:
- 1 ≤ m ≤ 120
- 2 ≤ length of words[i] ≤ 9×10⁴
學員剛讀題的時候明顯有點往「找替換字」這方向想。
我們在無痕聯機裡直接敲過去一句策略:
“不用管換成什麼字母,你只要遇到一對相鄰重複,就把 count++,然後跳過下一個字元。”
學員立刻理解,這題就直接平推過去了
第一題關鍵就在於:不要發散,不要去想字符集,只做計數和跳位。
2. Good Subsequences
A subsequence is created by deleting zero or more characters and concatenating the rest.
A subsequence is good when every character in it appears exactly the same number of times.
Empty subsequence is not allowed.
Example
word = "acaba"
Total non-empty subsequences = 31
Bad subsequences(frequencies not equal)示例包括 "aaa", "aca", "acaba" 共 3 个。
So total good subsequences = 31 − 3 = 28
Return 28 modulo (10⁹+7) → 28
Function Description
Complete the function countGoodSubsequences.
Parameters:
- string word
Returns: - int
Constraints:
- 1 ≤ length(word) ≤ 120000
- word consists of lowercase letters
我們給學員用的是 Palantir 老套路:
✓ Step 1:統計字母出現頻率 freq[c]
例如 s = “xxaby” → x:2, a:1, b:1, y:1
✓ Step 2:枚举一个可能的出现次数 k
k 從 1 到最大出現次數(例如 2)
✓ Step 3:只要 freq[c] ≥ k 的字母,都可以參與構成一次「每個字元都出現 k 次」 的 subsequence
假設 freq ≥ k 的字母個數是 M
那它們的任意非空子集都能組成一個合法 subsequence:
貢獻= 2^M – 1
✓ Step 4:所有 k 的貢獻求和
3. REST API: Population Density
Given a country name, call the API:
https://jsonmock.hackerrank.com/api/countries?name=<name>
Return population density = population / area as an integer.
If the country does not exist, return −1.
"data": [
{
"name": "Exampleland",
"population": 50234000,
"area": 152300
}
]
Density = 50234000 / 152300 ≈ 330 → return 330
If "data" is empty → return −1.
Function Description
Complete function getPopulationDensity(name).
Parameter:
- name: STRING
Return: - INTEGER density or −1
主要坑點:
- data 是空數組,不能存取 data[0]
- population 和 area 是數字,不要當字串
- area 可能是大整數,語言要注意類型
- URL 要精確匹配 name(大小寫敏感)
我們在線上幫學員快速檢查了一下邊界,確保不踩坑。
最終這一題基本上一次過。
從 OA 到 Offer,全程都有專業團隊為你護航
很多同學衝 Palantir、Citadel、Stripe、Amazon 時卡在的不是題本身,而是限時場景下的節奏、思維斷檔和 follow-up 追問Programhelp 做的,就是在這些關鍵節點給你「穩定輸出」的底氣。我們提供全連結助攻,包括 OA 線上支援、VO 即時思路提示、以及全流程陪同模式。 OA 部分使用 ToDesk 全程遠端連線,環境乾淨、不留痕跡,協助你把邏輯搭到位、測試案例跑乾淨,目標就是 100% 通過(未達成不收費)。 VO 面試由北美 CS 工程師團隊即時助攻,你自己出鏡,我們透過自主研發的無痕文字工具給你 coding 方向、follow-up 處理思路、BQ 邏輯、專案深挖要點與 system design 框架,幫助你在面試中保持節奏不掉線。另外也提供深度陪同服務,包括你出鏡的「對口型方式」與團隊代出鏡兩種模式,由我們事先準備腳本、模擬節奏,讓表達自然順口。如果你希望一路衝到拿 Offer,我們還有從 OA → VO → 談薪的一站式套餐,直到你拿到滿意 offer 為止。