Interview Questions/Coding/Secure Mirror Frame

Secure Mirror Frame

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Secure Mirror Frame

A security camera stores each frame as a binary matrix. Before review, the frame must be transformed row by row. For every row, first mirror the row horizontally. After mirroring, invert every bit in that row, changing 0 to 1 and 1 to 0. All rows are transformed independently. Input Format: You are given a 2D binary array frame. Output Format: Return the transformed binary frame.

Examples

Example 1
Input:
frame = [[1, 1, 0], [1, 0, 1], [0, 0, 0]]
Output:
1 0 0

Explanation: Each row is reversed and every bit is inverted: [1, 1, 0] -> [1, 0, 0]; [1, 0, 1] -> [0, 1, 0]; [0, 0, 0] -> [1, 1, 1]. The resulting frame is printed as shown.

Approach hint

Look for the state that actually matters after each operation.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp