2639. Find the Width of Columns of a Grid Easy
1/**
2 * [2639] Find the Width of Columns of a Grid
3 *
4 * You are given a 0-indexed m x n integer matrix grid. The width of a column is the maximum length of its integers.
5 *
6 * For example, if grid = [[-10], [3], [12]], the width of the only column is 3 since -10 is of length 3.
7 *
8 * Return an integer array ans of size n where ans[i] is the width of the i^th column.
9 * The length of an integer x with len digits is equal to len if x is non-negative, and len + 1 otherwise.
10 *
11 * <strong class="example">Example 1:
12 *
13 * Input: grid = [[1],[22],[333]]
14 * Output: [3]
15 * Explanation: In the 0^th column, 333 is of length 3.
16 *
17 * <strong class="example">Example 2:
18 *
19 * Input: grid = [[-15,1,3],[15,7,12],[5,6,-2]]
20 * Output: [3,1,2]
21 * Explanation:
22 * In the 0^th column, only -15 is of length 3.
23 * In the 1^st column, all integers are of length 1.
24 * In the 2^nd column, both 12 and -2 are of length 2.
25 *
26 *
27 * Constraints:
28 *
29 * m == grid.length
30 * n == grid[i].length
31 * 1 <= m, n <= 100
32 * -10^9 <= grid[r][c] <= 10^9
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/find-the-width-of-columns-of-a-grid/
38// discuss: https://leetcode.com/problems/find-the-width-of-columns-of-a-grid/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn find_column_width(grid: Vec<Vec<i32>>) -> Vec<i32> {
44 vec![]
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_2639() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.