More difficult than the question itself is the rhythm! Palantir OA's latest real-world replay, told in one sitting!

240 Views

This time, I'll accompany the students. Palantir OA , the overall feeling is: the topic itself is not biased, but the logical density is very high, and the time is pressed tight.
If you try to deviate a little bit, the whole question will be easily blown up. The student himself has a good foundation, but he tends to get nervous when doing the questions, and his steps will be messed up when he encounters combinations of questions, so this time he directly opened Programhelp's OA online help service without traces.
We synchronize reading and writing in an independent and clean environment without leaving any traces of operation, which is very friendly to this kind of OA with strong logic questions and time limits.

Here's a review of the three questions in order and how the pace was stabilized by assists at key points.

More difficult than the question itself is the rhythm! Palantir OA's latest real-world replay, told in one sitting!

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. Determine the minimal number of such substitutions so that the final string has no adjacent equal characters.

Exampl
words = ["seed", "baalll", "stone"]

  1. "seed" → the two e's are adjacent → 1 change
  2. "baalll" → there are two pairs ("aa", "ll") → 2 changes
  3. "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⁴

When the student first reads the question, it is obvious that he or she is thinking in the direction of "finding a replacement character".
We knocked right over a line of strategy in No Trace Online:

"Never mind switching to any letter, you just encounter a pair of neighboring duplicates, put count++, and skip the next character."

The learner immediately understood that the question panned right through.

Here's the key to the first question: don't get carried away, don't think about the character set, just do the counting and jumping bits.

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
Examples of bad subsequences (frequencies not equal) include "aaa", "aca", "acaba" common 3 Individuals.
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

We use the old Palantir routine for our trainees:

✓ Step 1: Count the frequency of letter occurrences freq[c]

For example s = "xxaby" → x:2, a:1, b:1, y:1

✓ Step 2: Enumerate the number of possible occurrences of a k

k from 1 to the maximum number of occurrences (e.g. 2)

✓ Step 3: Any letter with freq[c] ≥ k can participate in forming a subsequence where "each character occurs k times".

Suppose the number of letters with freq ≥ k is M
Then any non-empty subset of them can form a legal subsequence:

Contribution = 2^M - 1

✓ Step 4: Summing the contributions of all 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

Major Pit Points:

  1. data is an empty array, you can't access data[0].
  2. population and area are numbers, not strings.
  3. area may be a large integer, the language should be careful about the type
  4. URL to match name exactly (case sensitive)

We helped the trainee in the on-line to quickly check the boundaries and make sure they didn't step in the puddle.
Ultimately this question was basically passed in one sitting.

From OA to Offer, you will be escorted by a professional team.

What many students get stuck on when rushing Palantir, Citadel, Stripe, and Amazon is not the questions themselves, but rather the pace, breaks in thought, and follow-up questions in the time-limited scenarios.Programhelp give you the bottom of "stable output" in these key nodes. We provide a full chain of assistance, including OA on-line support, VO real-time thought prompts, and the whole process accompanied by the mode. OA part of the use of ToDesk full remote on-line, the environment is clean, do not leave traces, to assist you to put the logic in place, the test cases run clean, the goal is to 100% passed (not reached without charge). VO interviews are conducted by a team of North American CS engineers who assist you in real time, and you yourself appear in the mirror, and we give you coding direction, follow-up processing ideas, BQ logic, project digging points and system design frameworks through our self-developed non-trace text tool to help you keep the pace in the interview without dropping. In addition, we also provide in-depth accompanying services, including the "lip-synching mode" and the team on behalf of your appearance in two modes, we prepare scripts in advance, simulate the rhythm, so that the expression is natural and smooth. If you want to go all the way to get an offer, we also have a one-stop package from OA → VO → salary negotiation, until you get a satisfactory offer.

author avatar
Jory Wang Amazon Senior Software Development Engineer
Amazon senior engineer, focusing on the research and development of infrastructure core systems, with rich practical experience in system scalability, reliability and cost optimization. Currently focusing on FAANG SDE interview coaching, helping 30+ candidates successfully obtain L5/L6 Offers within one year.
END