FastPrepSquare-Neighborhood Image Blur
Problems/Square-Neighborhood Image Blur

Square-Neighborhood Image Blur

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Three ZipRecruiter new-grad OA reports preserve the radius square, center exclusion, floor neighbor mean, floor average with the original pixel, and no-neighbor preservation. The strongest image contract resolves a thinner occurrence's omitted rounding details.

For each grayscale pixel, consider all other in-bounds cells within row and column distance radius. Floor the neighbor mean, then floor the average of that mean and the original pixel. Preserve a pixel with no neighbors.

Return a new matrix using only original-image values for every calculation.

Function

blurImage(image: int[][], radius: int) → int[][]

Examples

Example 1

image = [[9,6],[3,0]]radius = 1return = [[6,5],[4,3]]
image
01096130
→
return
01065143
Moved or new

Each pixel sees the other three cells.

Example 2

image = [[7]]radius = 0return = [[7]]
image
007
→
return
007

The only pixel has no neighbor.

Constraints

  • 1 <= rows,columns <= 500
  • 0 <= pixel <= 255
  • 0 <= radius <= 500

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Split a Matrix Into Four Partitions by Average (Forward Deployed Engineer)Boston Consulting Group · OA
  • Leaves Remaining After Wind GustsOpenAI · OA
  • Shortest Path Around Rectangular ObstaclesDRW · OA
  • Sub-matrix SumsIMC Trading · OA
  • Largest Sub-GridMathWorks · OA
  • Maximum Trailing Zeros on a Path with at Most One TurnMarshall Wace · OA
  • Count L-Shaped PlotsUber · OA
  • Matrix Region SumRippling · OA · ONSITE INTERVIEW
  • Largest Square Sub-Grid Within a Sum LimitC3.ai · OA
  • Find Minimum Time to Create Beautiful CanvasAmazon · OA
See ZipRecruiter hiring insights
Saved
class Solution {
    public int[][] blurImage(int[][] image, int radius) {
        // Write your code here.
    }

}
Checking account…