Atlassian Dsa Round Question

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-06-23Added By Anonymous
Source: Link

Company: Atlassian
Role: p30, p40
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

You're working in a robotics factory. Each robot has a unique name, and each robot requires a standard set of parts (e.g., "sensors", "case", "speaker", etc.) to be fully assembled.

All parts in the factory bin are labeled in the format:   <robot_name>_<part_name>

Example:   "Rosie_claw", "Optimus_speaker", etc.

You are given: 1. A list of strings representing the available parts in the factory bin. 2. A string representing the comma-separated list of required parts needed to fully build one robot.

Task: Implement a function that returns the list of robot names for which we can build at least one complete robot from the available parts.

Function Signature:   public static String[] get_robots(String[] all_parts, String required_parts)

---

Sample Input:

String[] all_parts = {   "Rosie_claw",   "Rosie_sensors",   "Dustie_case",   "Optimus_sensors",   "Rust_sensors",   "Rosie_case",   "Rust_case",   "Optimus_speaker",   "Rosie_wheels",   "Rosie_speaker",   "Dustie_case",   "Dustie_arms",   "Rust_claw",   "Dustie_case",   "Dustie_speaker",   "Optimus_case",   "Optimus_wheels",   "Rust_legs",   "Optimus_sensors" };

String required_parts_1 = "sensors,case,speaker,wheels";
String required_parts_2 = "sensors,case,speaker,wheels,claw";
String required_parts_3 = "sensors,case,screws";

---

Expected Output:

get_robots(all_parts, required_parts_1) => ["Optimus", "Rosie"]
get_robots(all_parts, required_parts_2) => ["Rosie"]
get_robots(all_parts, required_parts_3) => []

(Note: The output order does not matter.)

---

Constraints: - N = number of parts in all_parts
- P = number of parts in required_parts
- Each part string is guaranteed to be in "<robot_name>_<part_name>" format
- Robot names are case-sensitive
- A robot may appear multiple times in the list with different parts

---

Follow-up discussion: - How would you scale this to millions of parts?
- Can you optimize for time and space complexity?
- What data structures help minimize lookup time?

Comments