FastPrepMake Pixel Columns Strictly Increasing
Problems/Make Pixel Columns Strictly Increasing

Make Pixel Columns Strictly Increasing

Microsoft logoMicrosoft● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft intern online assessment report included a photo of this task. You brighten pixels in a grid, paying 1 per unit, until each column gets strictly brighter from top to bottom, and you want the cheapest way to get there. The example from the photo, with a cost of 9, is Example 1 here.

The photo shows no limits on the grid size or the values and no function name. Here the grid has 1 to 100 rows and 1 to 100 columns, every value is from 0 to 10^9, the function is called getMinimumIncreaseCost, and it returns a 64-bit integer.

Our version is about 95% the same as the reported question.

An image is stored as a grid pixelIntensity with n rows and m columns. Each cell holds the brightness of one pixel.

The image is valid when, in every column, each pixel is strictly brighter than every pixel above it in that column. In other words, reading any column from top to bottom, the values strictly increase.

You may only make pixels brighter. Raising a pixel by 1 costs 1, so raising it by d costs d. Return the minimum total cost to make the image valid. The answer can exceed the 32-bit range, so return it as a 64-bit integer.

Function

getMinimumIncreaseCost(pixelIntensity: int[][]) → long

Examples

Example 1

pixelIntensity = [[2,5],[7,4],[3,5]]return = 9

Column 0 is 2, 7, 3. The first two values already increase, but 3 is not greater than 7, so it rises to 8 at a cost of 5. Column 1 is 5, 4, 5. The 4 must rise to 6 (cost 2), and then the last 5 must rise to 7 (cost 2), because it has to be greater than the new 6. The total cost is 5 + 2 + 2 = 9.

Example 2

pixelIntensity = [[5],[5],[5]]return = 3

The only column is 5, 5, 5. The top value stays, the middle one rises to 6 (cost 1) and the bottom one rises to 7 (cost 2). The total cost is 3.

Example 3

pixelIntensity = [[4,9,1]]return = 0

There is only one row, so every column has one pixel and nothing needs to change. The cost is 0.

Constraints

  • 1 <= n, m <= 100, where n is the number of rows and m is the number of columns.
  • 0 <= pixelIntensity[i][j] <= 10^9
  • All rows have the same length m.

More Microsoft Online Assessment questions

  • Minimum Cost to Process Priority TasksOA · Seen Nov 2026
  • Most Visited Sprint MarkerOA · Seen Nov 2026
  • Maximum Escape Game ScoreOA · Seen Nov 2026
  • Count Subarrays with a Perfect-Square ProductOA · Seen Nov 2026
  • Maximum Interactive Team SizeOA · Seen Nov 2026
  • Maximize Pipeline Throughput Under a Scaling BudgetOA · Seen Nov 2026
  • Minimum Cost K-Capable ModelsOA · Seen Nov 2026
  • Find Available Meeting RoomsOA · Seen Oct 2026
  • Maximum Sum of a K-StarOA · Seen Oct 2026
  • Capacity to Ship Packages Within DaysOA · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Minimum Row Deletions to Prevent a Target ORInMobi · ONSITE INTERVIEWInMobi interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Server InvestmentRippling · OARippling interview questions
  • Book Reading EveningsGoogle · OAGoogle interview questions
  • Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions
  • Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
  • Query a Header-Encoded MatrixNVIDIA · OANVIDIA interview questions
  • Minimum AmountBelvedere Trading · OA
  • Maximum Income from Asset TradingJefferies · OA
  • Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions

Interview reports that mention this question

  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)

Microsoft interview experiences

  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
  • Microsoft SWE Intern, Early 2026: 54 Experiences (Part 2 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public long getMinimumIncreaseCost(int[][] pixelIntensity) {
        // Write your code here.
    }
}
Checking account…