FastPrepMaximum-Weight Bipartite Matching
Problems/Maximum-Weight Bipartite Matching

Maximum-Weight Bipartite Matching

Google logoGoogle● HardNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names maximum-weight bipartite matching and a max-flow-style solution. Here we limit the size of the right side and use a bitmask DP, which keeps the same goal. Our version is about 90% the same as the reported question.

A rectangular matrix weights describes a bipartite graph. Row i is a left vertex and column j is a right vertex. A non-negative entry is the weight of edge (i,j); -1 means the edge is absent.

Choose edges of maximum total weight so that no vertex is used more than once. Vertices may remain unmatched. Return the maximum total weight as a signed 64-bit integer.

Function

maximumMatchingWeight(weights: int[][]) → long

Examples

Example 1

weights = [[5,1],[4,7]]return = 12

Match row 0 to column 0 and row 1 to column 1.

Example 2

weights = [[9,8,7],[6,-1,5]]return = 14

Choose weights 8 and 6 using distinct columns.

Example 3

weights = [[-1,-1],[3,-1]]return = 3

Only one available edge is useful; the other row stays unmatched.

Constraints

  • 0 <= rows <= 50.
  • 0 <= columns <= 15.
  • Every entry is -1 or lies in [0,10^9].

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Maximum Currency Conversion Along a Simple PathRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Minimum Semesters With Course CapacityAmazon · ONSITE INTERVIEW
  • Shortest Path Visiting All NodesInMobi · ONSITE INTERVIEWInMobi interview questions
  • Minimum Distance Matching in a ForestScale AI · PHONE SCREEN · ONSITE INTERVIEWScale AI interview questions
  • Longest Anchored Song ChainIntuit · OAIntuit interview questions
  • Cheapest Visiting Order with PrerequisitesIndeed · OAIndeed interview questions
  • Minimum Semesters with a Course LimitSnowflake · PHONE SCREENSnowflake interview questions
  • Count Routes Through Four Shop TypesOpenAI · OAOpenAI interview questions
  • Minimum Traveling Salesperson TourGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Grid Robot Route with Charging PrioritiesUber · PHONE SCREEN · ONSITE INTERVIEWUber interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public long maximumMatchingWeight(int[][] weights) {
        // Write your code here.
    }
}
Checking account…