Confluent's latest OA review|Two questions of medium-high intensity, full monitoring + detailed explanation of boundary pits

401 Views
No Comment

I just recently finished painting Confluent 's online assessment was slightly more difficult than expected. It was the type that looked simple but had many details and was prone to errors at the boundary conditions. The entire test consisted of two programming questions, with a total time of 65 minutes, and was completed on the HackerRank platform. Judging from the question types, this Confluent OA was clearly more focused on logic and data structure applications, rather than algorithm trap questions. It assessed whether your coding logic was clear and whether you could correctly handle boundary conditions.

Problem 1: Generate Two Binary Strings

Problem Description

Given an integer array Nums, generate two binary strings string1 And string2 of the same length.

  • string1[i] = '1' if Nums[i] has appeared before (in nums[0..i-1]), otherwise '0'.
  • string2[i] = '1' if Nums[i] will appear again later (in nums[i+1..n-1]), otherwise '0'.

Return [string1, string2].

Example

Input: nums = [1, 2, 1, 3]
Output: ["0010", "1000"]
Explanation.
string1 = "0010" because 1 appears again at index 2.
Explanation: string1 = "0010" because 1 appears again at index 2. string2 = "1000" because only nums[0] (1) appears later again.

Approach

The most straightforward solution is to use sets to record which elements have already been seen.

  • Traverse the array from left to right to build string1:
    • Maintain a seen set.
    • If Nums[i] is already in seen, append '1', otherwise '0' and add it to the set.
  • Traverse from right to left to build string2:
    • Maintain another set seen_from_right.
    • If Nums[i] appears again later (exists in the set), mark '1', else '0' and add it.

This approach takes O(n) time and O(n) Space, very clean and efficient.

Key Notes

When reading the questions, you should pay attention to the fact that "has appeared before" and "will appear again later" are two completely opposite judgments. It is easy to confuse the order of the questions when you read them for the first time, so we suggest that you compare them with the example, or else you will easily write them the other way around.

Problem 2: Duplicate Message Filter

Problem Description

A message delivery system needs to prevent duplicate messages from being sent within a short period of time.

If the same message has been successfully delivered within the last k seconds, then the new message should be considered a duplicate (False). Otherwise, it should be delivered (True) and update its last delivered timestamp.

You are given.

  • timestamps[i]: the arrival time of the i-th message (not necessarily sorted)
  • messages[i]: the message text
  • k: the time window in seconds

Return a boolean array indicating whether each message should be delivered (True) or dropped (False).

Example

Input.
timestamps = [1, 2, 4, 8, 10]
messages = ["a", "a", "a", "a", "a"]
k = 3

Output.
[True, False, True, True, False]

Explanation.

  • At t=1, "a" is new → deliver.
  • At t=2, "a" appeared 1s ago (<3) → drop.
  • At t = 4, difference = 3 → deliver (equal to k is allowed).
  • At t = 8, difference = 4 → deliver.
  • At t=10, difference = 2 (<3) → drop.

Approach

Use a dictionary to record the last delivered timestamp of each message.

last_time = {}
res = []

for t, msg in zip(timestamps, messages):
    if msg not in last_time or t - last_time[msg] >= k: res.append(True).
        res.append(True)
        last_time[msg] = t
    last_time[msg] = t else: res.append(True)
        res.append(False)

This works for both sorted and unsorted timestamps as long as you process them in input order.

Key Pitfall

Boundary conditions are the biggest catch in this question.
The question "within the last k seconds" means that any time difference less than k counts as a duplicate.is equal to k is allowed to send.
If the judgment is written as > rather than >=, which will directly result in half of the tests not being passed.

Also note that the inputs may not be in ascending order, and if they are entered in a chaotic order, they must be judged strictly in the order in which they were entered, and not sorted first, or else the logic will be wrong.

Overall Feeling and Strategies

The overall difficulty of this OA is in the Leetcode medium range, with the first question favoring logical construction and the second question favoring engineering implementation.
Neither question has a complex algorithm, but both require well-structured and well-bounded code.

Suggested time allocation:

  • The first question 20 minutes or so is sufficient and the code logic is very straightforward;
  • The second question 40 minutes is more stable, especially if you allow time to verify the boundaries;
  • Last 5 minutes to run all tests, check formatting.

If you are slow in reading English or if your logic is easily confused, we recommend that you familiarize yourself with the HackerRank test interface in advance, and think about the meaning of the inputs and outputs after reading through the examples.

Tips for getting through OA

If you've also been preparing for Online Assessment (OA) for Bloomberg, Amazon, Citadel, Meta, etc. lately, but are worried about time constraints, unfamiliar questions, and the fear of getting hung up on test cases, we can help.

Programhelp specializes in providing no trace OA Ancillary Services -- Remote connection through ToDesk, real-time synchronization of the screen, voice reminder ideas, the whole process is safe and does not leave traces.
pertain HackerRank, CodeSignal, Codility, Karat Common platforms, such as the guarantee that all test cases 100% pass, no charge if they do not pass.

If you want to securely pass OA and easily take the next round of opportunities, you can write to us privately for details, and we will customize the plan according to the position and company.

author avatar
jor jor
END
 0