2675. Find the Width of Columns of a Grid
My accepted Python solution to LeetCode problem 2675, Find the Width of Columns of a Grid, running in 7ms.
- Difficulty: Easy
- Python
- Runtime 7ms
- Memory 18.7MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 7ms, memory 18.7MB, accepted 2026-01-01.
class Solution:
def findColumnWidth(self, grid: List[List[int]]) -> List[int]:
m, n = len(grid), len(grid[0])
ans = [0] * n
for j in range(n):
for i in range(m):
ans[j] = max(ans[j], len(str(grid[i][j])))
return ans