Skip to content

Practice Find the Width of Columns of a Grid

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2639
LeetCode Problem

Find the Width of Columns of a Grid

Problem Statement

You are given a 0-indexed m x n integer matrix grid. The width of a column is the maximum length of its integers. Return an integer array ans of size n where ans[i] is the width of the ith column. The length of an integer x with len digits is equal to len if x is non-negative, and len + 1 otherwise.

Source: Find the Width of Columns of a Grid on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
grid = [[1],[22],[333]]
Output
[3]

# Example 2

Input
grid = [[-15,1,3],[15,7,12],[5,6,-2]]
Output
[3,1,2]

Constraints

m == grid.length
n == grid[i].length
1 <= m, n <= 100
-10^9 <= grid[r][c] <= 10^9

Related LeetCode Problems

Practice more problems similar to Find the Width of Columns of a Grid.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.