Atlassian technical phone interview: Department visit optimization coding
Interview Experience
Problem Given a product catalog linking items to departments and an ordered shopping list, calculate the efficiency gained by grouping items by department rather than picking them up in the order
Full Details
Problem Given a product catalog linking items to departments and an ordered shopping list, calculate the efficiency gained by grouping items by department rather than picking them up in the order written.
Return an integer representing the number of department visits saved. This is calculated as: (Visits required by following the list order) - (Visits required by grouping by department)
Logic 1.
List Order Visits: Iterate through the shopping list. A new department visit is counted every time the department of the current item differs from the previous item. 2.
Optimized Visits: Count the number of unique departments represented in the shopping list. 3.
Result: Subtract the Optimized count from the List Order count.
Data
text products = [["Cheese", "Dairy"], ["Carrots", "Produce"], ["Potatoes", "Produce"], ["Canned Tuna", "Pantry"], ["Romaine Lettuce", "Produce"], ["Chocolate Milk", "Dairy"], ["Flour", "Pantry"], ["Iceberg Lettuce", "Produce"], ["Coffee", "Pantry"], ["Pasta", "Pantry"], ["Milk", "Dairy"], ["Blueberries", "Produce"], ["Pasta Sauce", "Pantry"]]
Walkthrough
Input: list1 = ["Blueberries", "Milk", "Coffee", "Flour", "Cheese", "Carrots"] *
List Order: 1. Blueberries (Produce) 2. Milk (Dairy) — Change 3. Coffee (Pantry) — Change 4. Flour (Pantry) — No Change 5. Cheese (Dairy) — Change 6. Carrots (Produce) — Change * Path: Produce -> Dairy -> Pantry -> Dairy -> Produce * Total Visits: 5 *
Optimized: * Unique Departments: Produce, Dairy, Pantry * Total Visits: 3 *
Saved: 5 - 3 = 2
Test Cases
text shopping(products, ["Blueberries", "Milk", "Coffee", "Flour", "Cheese", "Carrots"]) => 2 shopping(products, ["Blueberries", "Carrots", "Coffee", "Milk", "Flour", "Cheese"]) => 2 shopping(products, ["Blueberries", "Carrots", "Romaine Lettuce", "Iceberg Lettuce"]) => 0 shopping(products, ["Milk", "Flour", "Chocolate Milk", "Pasta Sauce"]) => 2 shopping(products, ["Cheese", "Potatoes", "Blueberries", "Canned Tuna"]) => 0
About This Question
This is a candidate experience report from a atlassian interview for a swe role during the phone screen round reported in 2025.
It covers the following topics: General Experience .