Class Solution
java.lang.Object
g0801_0900.s0832_flipping_an_image.Solution
832 - Flipping an Image.<p>Easy</p>
<p>Given an <code>n x n</code> binary matrix <code>image</code>, flip the image <strong>horizontally</strong> , then invert it, and return <em>the resulting image</em>.</p>
<p>To flip an image horizontally means that each row of the image is reversed.</p>
<ul>
<li>For example, flipping <code>[1,1,0]</code> horizontally results in <code>[0,1,1]</code>.</li>
</ul>
<p>To invert an image means that each <code>0</code> is replaced by <code>1</code>, and each <code>1</code> is replaced by <code>0</code>.</p>
<ul>
<li>For example, inverting <code>[0,1,1]</code> results in <code>[1,0,0]</code>.</li>
</ul>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> image = [[1,1,0],[1,0,1],[0,0,0]]</p>
<p><strong>Output:</strong> [[1,0,0],[0,1,0],[1,1,1]]</p>
<p><strong>Explanation:</strong></p>
<p>First reverse each row: [[0,1,1],[1,0,1],[0,0,0]].</p>
<p>Then, invert the image: [[1,0,0],[0,1,0],[1,1,1]]</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> image = [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]]</p>
<p><strong>Output:</strong> [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]</p>
<p><strong>Explanation:</strong></p>
<p>First reverse each row: [[0,0,1,1],[1,0,0,1],[1,1,1,0],[0,1,0,1]].</p>
<p>Then invert the image: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == image.length</code></li>
<li><code>n == image[i].length</code></li>
<li><code>1 <= n <= 20</code></li>
<li><code>images[i][j]</code> is either <code>0</code> or <code>1</code>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
flipAndInvertImage
public int[][] flipAndInvertImage(int[][] image)
-