832. Flipping an Image Easy
1/**
2 * [832] Flipping an Image
3 *
4 * Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
5 * To flip an image horizontally means that each row of the image is reversed.
6 *
7 * For example, flipping [1,1,0] horizontally results in [0,1,1].
8 *
9 * To invert an image means that each 0 is replaced by 1, and each 1 is replaced by 0.
10 *
11 * For example, inverting [0,1,1] results in [1,0,0].
12 *
13 *
14 * Example 1:
15 *
16 * Input: image = [[1,1,0],[1,0,1],[0,0,0]]
17 * Output: [[1,0,0],[0,1,0],[1,1,1]]
18 * Explanation: First reverse each row: [[0,1,1],[1,0,1],[0,0,0]].
19 * Then, invert the image: [[1,0,0],[0,1,0],[1,1,1]]
20 *
21 * Example 2:
22 *
23 * Input: image = [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]]
24 * Output: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]
25 * Explanation: First reverse each row: [[0,0,1,1],[1,0,0,1],[1,1,1,0],[0,1,0,1]].
26 * Then invert the image: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]
27 *
28 *
29 * Constraints:
30 *
31 * n == image.length
32 * n == image[i].length
33 * 1 <= n <= 20
34 * images[i][j] is either 0 or 1.
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/flipping-an-image/
40// discuss: https://leetcode.com/problems/flipping-an-image/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn flip_and_invert_image(image: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
46 vec![]
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_832() {
58 }
59}
60
Back
© 2025 bowen.ge All Rights Reserved.