Description

Given a binary matrix image, first flip the image horizontally (reverse each row), then invert it (replace 0 with 1 and 1 with 0). Return the resulting image.

Examples

Input:image = [[1,1,0],[1,0,1]]
Output:[[1,0,0],[0,1,0]]
Explanation:

Flip then invert.

Input:image = [[0]]
Output:[[1]]
Explanation:

Single element case: flip horizontally (no change since only one element), then invert 0 to 1.

Input:image = [[0,1,1,0,1],[1,0,0,1,0]]
Output:[[0,1,0,0,1],[1,0,1,1,0]]
Explanation:

Odd-length rows: First row [0,1,1,0,1] flips to [1,0,1,1,0], then inverts to [0,1,0,0,1]. Second row [1,0,0,1,0] flips to [0,1,0,0,1], then inverts to [1,0,1,1,0].

Constraints

  • 1 ≤ n ≤ 20

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!