• 문제 링크
Flipping an Image - LeetCode
Can you solve this real interview question? Flipping an Image - Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed. * F
leetcode.com
• 풀이 코드
public class Solution {
public int[][] flipAndInvertImage(int[][] image) {
int n = image.length;
for (int[] row : image) {
int l = 0, r = n - 1;
while (l <= r) {
int temp = row[l] ^ 1;
row[l++] = row[r] ^ 1;
row[r--] = temp;
}
}
return image;
}
}'Problem Solving > LeetCode' 카테고리의 다른 글
| [LeetCode] 844. Backspace String Compare - Java (0) | 2026.10.25 |
|---|---|
| [LeetCode] 836. Rectangle Overlap - Java (0) | 2026.10.24 |
| [LeetCode] 830. Positions of Large Groups - Java (0) | 2026.10.23 |
| [LeetCode] 824. Goat Latin - Java (0) | 2026.10.21 |
| [LeetCode] 821. Shortest Distance to a Character - Java (0) | 2026.10.20 |
댓글