Team Outing
Updated
Problem statement
Office 0, employees 1..n, and destination n+1 are locations in the distances matrix. Partition all employees into nonempty groups of consecutive employee IDs. Assign one cab to each group. A cab starts at the office, visits exactly its assigned employees in any order, then reaches the destination. It returns along the exact same route in reverse.
A cab costs baseFare + perDistance * its total round-trip distance. Capacity and cab supply are unlimited. Return the minimum total fare. Use the given matrix entry as the cost of each leg; do not replace it by an indirect path through other locations. Consecutive group membership does not require visiting employees in ID order.
Function
teamOuting(distances: int[][], baseFare: int, perDistance: int) → longExamples
Example 1
distances = [[0,5,8,9,10],[5,0,10,5,6],[8,10,0,6,9],[9,5,6,0,7],[10,6,9,7,0]]baseFare = 1000perDistance = 50return = 3500One optimal outbound visit order is 0,1,3,2,4 with distance 25; the round trip costs 1000+50*50=3500.
Example 2
distances = [[0,1,1,1],[1,0,1,1],[1,1,0,1],[1,1,1,0]]baseFare = 10perDistance = 2return = 22One cab has three outbound legs and six round-trip units, costing 10+2*6.
Constraints
- 1 <= n <= 15, 0 <= baseFare <= 100000, and 0 <= perDistance <= 1000.
- For this exercise, distances is a symmetric (n+2) by (n+2) matrix with zero diagonal and other values between
0and10^6. Return a signed 64-bit fare.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Maximum Square-Free DivisorOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
Similar questions at other companies
- Count Routes Through Four Shop TypesOpenAI · OAOpenAI interview questions
- Vehicle Builds for Required Terrain (Game Adaptation)Roblox · OARoblox interview questions
- Minimum Moves to Spread Stones Across a GridAmerican Express · OAAmerican Express interview questions
- Maximum Profit Under a Bitwise OR LimitConcentric AI · OAConcentric AI interview questions
- Bitwise XOR SubsequencesJP Morgan Chase · OAJP Morgan Chase interview questions
- Beautiful Number OrderingsDocuSign · OADocuSign interview questions
- Minimum Operations To Reduce To ZeroUber · OAUber interview questions
- Bitwise XOR SubsequencesGoldman Sachs · OAGoldman Sachs interview questions
- Delete K Subsets for Maximum ScoreRubrik · OARubrik interview questions
- Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions