这次陪学员过 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 the final 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 为止。