Find Minimum Time to Create Beautiful Canvas
Learn this problemProblem statement
Amazon is introducing an innovative smart canvas display for personalized home decor. The canvas is initially painted white, featuring n rows and m columns, waiting to be transformed into a beautiful masterpiece. Each minute, the canvas undergoes a unique coloring process as specified by the user.
A beautiful canvas is defined by the presence of a square with a side length of k where all cells within the square are elegantly colored.
Determine the minimum time required for the canvas to achieve its beauty.
Formally, Given n and m that denote the number of rows and columns of the canvas respectively, k denotes the size of the square, and a 2D array paint of dimensions (n * m) rows and 2 columns, where each entry (paint[i][0], paint[i][1]) represents the coordinates of a cell to be painted black during the ith minute.
Note that each cell is painted only once during this transformation.
Find the minimum time (in minutes) after which the canvas becomes beautiful.
Function
findMinimumTime(n: int, m: int, k: int, paint: int[][]) → intExamples
Example 1
n = 2m = 3k = 2paint = [[1, 2], [2, 3], [2, 1], [1, 3], [2, 2], [1, 1]]return = 5
Constraints
1 ≤ n, m ≤ 7501 ≤ k ≤ min(n, m)1 ≤ paint[i][0] ≤ n1 ≤ paint[i][1] ≤ mpaint[i] ≠ paint[j]for any1 ≤ i < j ≤ n*m
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026