FastPrepCenter Crop a Grayscale Image
Problems/Center Crop a Grayscale Image

Center Crop a Grayscale Image

Luma AI logoLuma AI● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Luma AI assessment report gives the full function signature for center-cropping a 2D integer image. Our version keeps it. Our version is about 99% the same as the reported question.

Given a rectangular grayscale image image, return its centered cropHeight × cropWidth crop.

The parity guarantees make the unused rows and columns split evenly across opposite sides.

Function

centerCrop(image: int[][], cropHeight: int, cropWidth: int) → int[][]

Examples

Example 1

image = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]cropHeight = 1cropWidth = 2return = [[6,7]]
image
0123012341567829101112
→
return
01067

One row and one column are removed evenly from opposite sides.

Constraints

  • 1 <= image.length, image[i].length <= 200.
  • 1 <= cropHeight <= image.length and 1 <= cropWidth <= image[i].length.
  • (image.length - cropHeight) and (image[i].length - cropWidth) are even.

More Luma AI Online Assessment questions

  • Build a Gaussian Blur KernelOA · Seen Jun 2026
  • Impute Missing Values and Normalize ColumnsOA · Seen Jun 2026
  • Minimum Euclidean Distance Between PointsOA · Seen Jun 2026
  • Numerically Stable SoftmaxOA · Seen Jun 2026
  • Rotate a Rectangular Image ClockwiseOA · Seen Jun 2026
  • Triangle Flags from Adjacent ElementsOA · Seen Jun 2026

Similar questions at other companies

  • Survey Table: Group Given an AnswerSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions
  • Query a Header-Encoded MatrixNVIDIA · OANVIDIA interview questions
  • Count Pieces After Othello MovesHudson River Trading · OAHudson River Trading interview questions
  • Trapped Characters in a GridAdobe · OAAdobe interview questions
  • Find Zero Cells in a 2×2 GridRoblox · OARoblox interview questions
  • Make Pixel Columns Strictly IncreasingMicrosoft · OAMicrosoft interview questions
  • Check Matrix Reflection SymmetryIntuit · OAIntuit interview questions
  • Tic-Tac-Toe Board StatusPinecone · OA
  • Cherry PickupInfosys · OAInfosys interview questions
All Luma AI interview questionsSee Luma AI hiring insights
Saved
class Solution {
    public int[][] centerCrop(int[][] image, int cropHeight, int cropWidth) {
        // Return the centered crop.
    }
}
Checking account…