Buildable Robots from Available Part Types
Updated
Problem statement
Given requirements and available, return the names of all robots that can be built, in lexicographic order.
Each string in requirements has the form Robot_Part and means that robot needs that part type. available lists the part types you have. A robot can be built only if every part type it needs is in available, so a single missing type such as claw blocks it. Only robots named in requirements count.
Part types are reusable, not counted. Duplicate entries in either list do not change the answer, and building one robot does not use up parts another robot needs. If requirements is empty, return an empty list.
Function
buildableRobots(requirements: String[], available: String[]) → String[]Examples
Example 1
requirements = ["Rosie_claw","Rosie_sensors","Dustie_case","Optimus_sensors","Rust_sensors","Rosie_case","Rust_case","Optimus_speaker","Rosie_wheels","Dustie_case","Dustie_arms","Rust_claw","Dustie_case","Dustie_speaker","Optimus_case","Optimus_wheels","Optimus_wheels","Rust_legs","Optimus_sensors"]available = ["sensors","case","speaker","wheels"]return = ["Optimus"]Optimus has every required part. Rosie lacks claw, Dustie lacks arms, and Rust lacks claw and legs.
Example 2
requirements = ["Rosie_claw","Rosie_sensors","Dustie_case","Optimus_sensors","Rust_sensors","Rosie_case","Rust_case","Optimus_speaker","Rosie_wheels","Dustie_case","Dustie_arms","Rust_claw","Dustie_case","Dustie_speaker","Optimus_case","Optimus_wheels","Optimus_wheels","Rust_legs","Optimus_sensors"]available = ["sensors","case","speaker","wheels","claw"]return = ["Optimus","Rosie"]Adding claw makes Rosie buildable; the other missing parts still block Dustie and Rust.
Example 3
requirements = ["A_case","B_case","A_case"]available = ["case"]return = ["A","B"]Both robots need only case. Repeated requirements do not consume extra parts.
Constraints
0 <= requirements.length, available.length <= 500.- Each requirement has exactly one underscore separating a nonempty robot name from a nonempty part name.
- Names have
1through30ASCII letters or digits, contain no underscores, and are case-sensitive.
More Atlassian Phone Screen questions
- Merge Overlapping IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Tennis Court SchedulingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
- Longest Consistent Activity StreakPHONE SCREEN · Seen Sep 2026
- Music Player Operation SequencePHONE SCREEN · Seen Sep 2026
- Underline Shortest Unique SubstringsPHONE SCREEN · Seen Aug 2026
- Can a Dictionary Word Be Formed from Note Letters?PHONE SCREEN · Seen Feb 2026
- Word Path Moving Only Right or DownPHONE SCREEN · Seen Feb 2026
- Ordered Badge Entry and Exit ViolationsPHONE SCREEN · Seen Aug 2025
- Two Sum with an Ordered Index PairPHONE SCREEN · Seen Aug 2025
Similar questions at other companies
- Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
- Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- Most Frequent NameAmazon · PHONE SCREEN
- Words with Repeated AnagramsThe Voleon Group · PHONE SCREEN
- Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
- Product Keyword SearchTesco · PHONE SCREEN
- Verify Words Sorted by a Custom AlphabetTrueFoundry · PHONE SCREEN
- Character Frequencies Across Nested String ListsSnowflake · PHONE SCREENSnowflake interview questions