FastPrepCommunications Handler
Problems/Communications Handler

Communications Handler

Akuna Capital logoAkuna Capital● MediumNEW GRADOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: 🦦 This practice version is about an 85% match to the available screenshot. The three operations and their messages follow the source. Because the sample case and custom-input format are hidden, FastPrep enriched those missing pieces while strictly preserving the original problem's intent.

Implement a communications handler for a single shared communication channel. At most two callers can communicate at a time, and no other pair can connect until the current communication ends.

The input instructions describes method calls in chronological order:

  • ["connect", user1, user2] calls connect for the two named callers.
  • ["hangup", user1, user2] calls hangup for the two named callers.
  • ["clear_all"] calls clear_all.

Caller names uniquely identify the corresponding Caller objects. Treat a connected pair as unordered, so either caller order refers to the same active communication.

Connect

  • If user1 and user2 are the same caller, the call raises CommunicationException with the message {user1} cannot connect with {user2}.
  • If the callers are different but the line is already in use, the call raises CommunicationException with the message Connection in use. Please try later.
  • Otherwise, store the two callers as the active pair and return Connection established between {user1} and {user2}.

Hangup

  • If user1 and user2 are the same caller, the call raises CommunicationException with the message {user1} cannot hangup with {user2}.
  • If the two callers are the active pair, disconnect them and return {user1} and {user2} are disconnected.
  • Otherwise, the call raises CommunicationException with the message {user1} and {user2} not found in the communication channel.

Clear All

clear_all clears the channel regardless of its current users.

Return an array containing, in order, the returned string or exception message from every connect and hangup instruction. A clear_all instruction produces no output entry.

Function

handleCommunications(instructions: String[][]) → String[]

Examples

Example 1

instructions = [["connect","Alice","Bob"],["connect","Carol","Dave"],["hangup","Bob","Alice"],["connect","Carol","Dave"]]return = ["Connection established between Alice and Bob","Connection in use. Please try later","Bob and Alice are disconnected.","Connection established between Carol and Dave"]
  1. Alice and Bob occupy the free channel.
  2. Carol and Dave cannot connect while that pair remains active.
  3. hangup accepts the active pair in reverse order and frees the channel.
  4. Carol and Dave can then connect.

Example 2

instructions = [["connect","Mia","Mia"],["hangup","Mia","Noah"],["connect","Mia","Noah"],["hangup","Mia","Mia"],["hangup","Noah","Mia"]]return = ["Mia cannot connect with Mia","Mia and Noah not found in the communication channel.","Connection established between Mia and Noah","Mia cannot hangup with Mia","Noah and Mia are disconnected."]

The rejected same-caller calls do not change the channel. The final reversed-order hangup matches the active pair and disconnects it.

Example 3

instructions = [["connect","Ava","Ben"],["clear_all"],["hangup","Ava","Ben"],["connect","Cara","Dan"]]return = ["Connection established between Ava and Ben","Ava and Ben not found in the communication channel.","Connection established between Cara and Dan"]

clear_all removes Ava and Ben without adding an output entry. Their later hangup is therefore not found, and the channel remains available for Cara and Dan.

Constraints

  • 1 <= instructions.length <= 2000.
  • At most 100 distinct caller names appear.
  • Every instruction is one of ["connect", user1, user2], ["hangup", user1, user2], or ["clear_all"].
  • Every caller name is a non-empty, case-sensitive string that uniquely identifies one caller.

More Akuna Capital Online Assessment questions

  • Last Digit of the Ways to Split Traders Between Two OfficesOA · Seen Dec 2026
  • Light Bulbs Left On After All Engineers FinishOA · Seen Dec 2026
  • Delivery Management SystemOA · Seen Nov 2026
  • Count Server ReplacementsOA · Seen Nov 2026
  • Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximum Remaining Drone PowerOA · Seen Nov 2026
  • Rolling MetricsOA · Seen Oct 2026
  • Vowel Substring GameOA · Seen Sep 2026
  • Competitive ForagingOA · Seen Sep 2026
  • Binary CircuitOA · Seen Sep 2026

Similar questions at other companies

  • Reliable LLM Call with Independent Retry BudgetsStripe · OAStripe interview questions
  • Parcel Event TrackingAirbnb · OAAirbnb interview questions
  • Text Editor OperationsMicrosoft · OAMicrosoft interview questions
  • Versioned Recipe SystemThe Trade Desk · OA
  • File System Shell CommandsHarvey · ONSITE INTERVIEWHarvey interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Stateful Log Transform and SearchRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • Query JSON Records with WHERE and ORDER BYGitHub · ONSITE INTERVIEW
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions

Akuna Capital interview experiences

  • Akuna Capital Quant Trader and QR Interviews: 5 Experiences
  • Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
  • Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
  • Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
  • Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)
  • Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)
All Akuna Capital interview questionsSee Akuna Capital hiring insights
Saved
class Solution {
    public String[] handleCommunications(String[][] instructions) {
        // write your code here
    }

}
Checking account…