Class Solution
-
- All Implemented Interfaces:
public final class Solution2639 - Find the Width of Columns of a Grid.
Easy
You are given a 0-indexed
m x ninteger matrixgrid. The width of a column is the maximum length of its integers.For example, if
grid = \[\[-10], [3], [12]], the width of the only column is3since-10is of length3.
Return an integer array
ansof sizenwhereans[i]is the width of the <code>i<sup>th</sup></code> column.The length of an integer
xwithlendigits is equal tolenifxis non-negative, andlen + 1otherwise.Example 1:
Input: grid = \[\[1],22,333]
Output: 3
Explanation: In the 0<sup>th</sup> column, 333 is of length 3.
Example 2:
Input: grid = \[\[-15,1,3],15,7,12,5,6,-2]
Output: 3,1,2
Explanation:
In the 0<sup>th</sup> column, only -15 is of length 3.
In the 1<sup>st</sup> column, all integers are of length 1.
In the 2<sup>nd</sup> column, both 12 and -2 are of length 2.
Constraints:
m == grid.lengthn == grid[i].length1 <= m, n <= 100<code>-10<sup>9</sup><= gridc<= 10<sup>9</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntArrayfindColumnWidth(Array<IntArray> grid)-
-
Method Detail
-
findColumnWidth
final IntArray findColumnWidth(Array<IntArray> grid)
-
-
-
-