2025-08-21 10:40:48 +0000 UTC
Find the Width of Columns of a Grid
Categories:
Links
Code
class Solution:
def findColumnWidth(self, grid: List[List[int]]) -> List[int]:
res = []
for col in range(len(grid[0])):
max_len = 0
for row in range(len(grid)):
val = grid[row][col]
if val == 0:
count = 1
elif val < 0:
count = 1
val = -val
else:
count = 0
while val > 0:
count += 1
val //= 10
max_len = max(max_len, count)
res.append(max_len)
return res