FastPrepTransform Binary Matrix
Problems/Transform Binary Matrix

Transform Binary Matrix

Visa logoVisa● EasyOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

You are given an n x n binary matrix representing an image.

Your task is to transform the image by applying the following operations in order:

  • Rotate the image clockwise by rotation degrees.
    • rotation is one of 90, 180, or 270.
  • If vertical_flip = 1, flip the image vertically, top to bottom.
  • If horizontal_flip = 1, flip the image horizontally, left to right.

Return the final transformed binary matrix after all operations are applied.

Function

transformImage(n: int, rotation: int, vertical_flip: int, horizontal_flip: int, image: int[][]) → int[][]

Examples

Example 1

n = 3rotation = 270vertical_flip = 0horizontal_flip = 1image = [[1,0,0],[0,1,1],[0,0,1]]return = [[1,1,0],[0,1,0],[0,0,1]]
image
012010010112001
→
return
012011010102001
Moved or new

Original pixels:

[[1,0,0],
 [0,1,1],
 [0,0,1]]

Rotate the image by 270 degrees clockwise:

[[0,1,1],
 [0,1,0],
 [1,0,0]]

vertical_flip is 0, so the image is not flipped vertically.

Perform the horizontal flip:

[[1,1,0],
 [0,1,0],
 [0,0,1]]

Note: The screenshot did not show a separate output line. FastPrep calculated this matrix from the visible rotation and flip steps so you can practice with a complete example. 🐥

More Visa Online Assessment questions

  • Count Prime Values in SubtreesOA · Seen Nov 2026
  • Lock CodeOA · Seen Nov 2026
  • Minimum-Sum Tree Fill with Unit StepsOA · Seen Nov 2026
  • Longest Non-Decreasing Substring After Pair SwapsOA · Seen Oct 2026
  • Count Attack Vectors by Divisor RangeOA · Seen Oct 2026
  • Minimum Operations to Reduce a Transaction LedgerOA · Seen Oct 2026
  • Count Valid Space-Delimited WordsOA · Seen Oct 2026
  • Earliest Common Meeting StartOA · Seen Oct 2026
  • Maximum Index-Weighted Sum with Disjoint SwapsOA · Seen Oct 2026
  • Maximum Equalized Substrings After One Adjacent SwapOA · Seen Sep 2026

Similar questions at other companies

  • Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions
  • Invert or Blur an ImageOpenAI · OAOpenAI interview questions
  • Count Pieces After Othello MovesHudson River Trading · OAHudson River Trading interview questions
  • Trapped Characters in a GridAdobe · OAAdobe interview questions
  • Simulate a Deterministic Finite AutomatonPoint72 · OAPoint72 interview questions
  • Collect Letters Along a Unique Grid PathApple · OAApple interview questions
  • Rover MoveIBM · OAIBM interview questions
  • Tic-Tac-Toe Board StatusPinecone · OA
  • Orthogonal Neighbor Grid TotalIMC Trading · OAIMC Trading interview questions
  • Robo Data Sharing DirectionArcesium · OAArcesium interview questions
All Visa interview questionsSee Visa hiring insights
Saved
class Solution {
    public int[][] transformImage(int n, int rotation, int vertical_flip, int horizontal_flip, int[][] image) {
      // write your code here
    }
}
Checking account…