LeetCode solutions

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

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 7ms, memory 18.7MB, accepted 2026-01-01.

python
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

Source