FastPrepMinimum Traveling Salesperson Tour
Problems/Minimum Traveling Salesperson Tour

Minimum Traveling Salesperson Tour

Goldman Sachs logoGoldman Sachs● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names the traveling-salesperson problem and bitmask dynamic programming. We chose the usual closed tour, a complete directed matrix of integer costs, a fixed starting vertex, and small limits. Our version is about 85% the same as the reported question.

You are given a complete directed graph as a square matrix cost. A traveler starts at vertex 0, visits every other vertex exactly once, and returns to vertex 0.

Return the minimum total edge cost of such a tour. The cost from one vertex to another may differ from the cost of the reverse trip. Costs may be zero. The diagonal is zero. With one vertex, the tour has cost zero.

Use subset dynamic programming with a bitmask for the visited vertices.

Function

minimumTourCost(cost: int[][]) → long

Examples

Example 1

cost = [[0,3,8],[5,0,2],[4,7,0]]return = 9

The tour 0 to 1 to 2 to 0 costs 3+2+4=9; the other ordering costs 20.

Example 2

cost = [[0]]return = 0

There is no edge to traverse with a single vertex.

Constraints

  • 1 <= cost.length <= 14.
  • Every row has the same length as the number of vertices.
  • 0 <= cost[i][j] <= 10^6, and cost[i][i] = 0.

More Goldman Sachs Phone Screen questions

  • House Robber IIIPHONE SCREEN · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · Seen Nov 2026
  • Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Check a Complete Binary TreePHONE SCREEN · Seen Oct 2026
  • Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Count Staircase WaysPHONE SCREEN · Seen Oct 2026
  • Is a Power of TenPHONE SCREEN · Seen Oct 2026
  • Square Root with Newton IterationPHONE SCREEN · Seen Oct 2026
  • First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Root of the Largest TreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Maximum Currency Conversion Along a Simple PathRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Minimum Distance Matching in a ForestScale AI · PHONE SCREEN · ONSITE INTERVIEWScale AI interview questions
  • Minimum Semesters with a Course LimitSnowflake · PHONE SCREENSnowflake interview questions
  • Count Routes Through Four Shop TypesOpenAI · OAOpenAI interview questions
  • Shortest Round Trip Through All DeliveriesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Minimum Semesters With Course CapacityAmazon · ONSITE INTERVIEW
  • Shortest Path Visiting All NodesInMobi · ONSITE INTERVIEWInMobi interview questions
  • Longest Anchored Song ChainIntuit · OAIntuit interview questions
  • Cheapest Visiting Order with PrerequisitesIndeed · OAIndeed interview questions
  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public long minimumTourCost(int[][] cost) {
        // Write your code here.
    }
}
Checking account…