GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesMatrix Chain Factory

Gamified challenge · Interval DP

Matrix Chain Factory

The chain has n = dims.length - 1 matrices M1 … Mn, where Mi has dims[i-1] rows and dims[i] columns, so neighbours always fit. Multiplying an a × b matrix by a b × c matrix costs a · b · c scalar multiplications and gives an a × c matrix.

The product is the same however you bracket it, but the work is not. Write minMults(dims) (Python min_mults) that returns the least total work for the whole chain. dims has at least 2 numbers; a single matrix costs 0.

Example: for [10, 30, 5, 60], (M1 M2) M3 costs 10·30·5 + 10·5·60 = 4500, while M1 (M2 M3) costs 30·5·60 + 10·30·60 = 27000. The answer is 4500.

Sign in to play Matrix Chain Factory

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account