FastPrepOutline of Shapes in an Image
Problems/Outline of Shapes in an Image

Outline of Shapes in an Image

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem keeps only the outline pixels of the shapes in a black-and-white image. A post from May 2021 covers the author's virtual interviews at two companies. In its Adobe part, the hour-long first technical round asked, in a single line, for the shapes in a supplied picture to be traced around their edges. The author reports reaching a solution with depth-first search after a slow start. The interviewer allowed image-library calls and colour values to be taken as given, since the task leans on imaging knowledge. The post defines no input, output or outline rule. Our saved copy holds only its opening and this round.

Our reading and choices: the image is a grid of 0 (background) and 1 (ink) instead of colour values. Neighbours share a side. Background joined to the image edge through neighbours is the outside, so closed holes are not. An ink pixel is outline when it is on the image edge or next to outside background. The answer is a same-size grid with 1 on outline pixels. The image is up to 40 x 40 pixels. The examples are new.

Because the outline rule is our reading, our version is about 50% the same as the reported question.

A black-and-white image is given as a grid image, where 1 is an ink pixel and 0 is a background pixel. Two pixels are neighbours if they share a side (up, down, left or right; corners do not count).

The outside is every background pixel that can be reached from a background pixel on the edge of the image by moving between neighbouring background pixels. Background pixels that cannot be reached this way are closed holes, not outside.

An ink pixel is an outline pixel if it lies on the edge of the image or has an outside pixel as a neighbour. Return a grid of the same size with 1 on every outline pixel and 0 everywhere else.

Function

outlinePixels(image: int[][]) → int[][]

Examples

Example 1

image = [[0,0,0,0,0,0],[0,1,1,1,1,0],[0,1,1,1,1,0],[0,1,1,0,1,0],[0,1,1,1,1,0],[0,0,0,0,0,0]]return = [[0,0,0,0,0,0],[0,1,1,1,1,0],[0,1,0,0,1,0],[0,1,0,0,1,0],[0,1,1,1,1,0],[0,0,0,0,0,0]]
image
012345000000010111102011110301101040111105000000
→
return
012345000000010111102010010301001040111105000000
Moved or new

Counting rows and columns from 0, the 4 x 4 block has a closed hole at row 3, column 3. Its 12 edge pixels touch the outside background, so they are kept. The pixels at (2, 2), (2, 3) and (3, 2) touch only ink or the closed hole, so they become 0.

Example 2

image = [[1,1,0,0],[1,1,1,0],[1,1,1,1]]return = [[1,1,0,0],[1,0,1,0],[1,1,1,1]]
image
0123011001111021111
→
return
0123011001101021111
Moved or new

Ink pixels on the edge of the image count as outline. Counting from 0, pixel (1, 2) touches the outside background above it. Only (1, 1) is surrounded by ink on all four sides, so it becomes 0.

Example 3

image = [[0,0],[0,0]]return = [[0,0],[0,0]]
image
01000100
→
return
01000100

There is no ink, so the outline is empty: every pixel is 0.

Constraints

  • 1 <= image.length, image[i].length <= 40
  • All rows of image have the same length.
  • image[i][j] is 0 or 1

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Number of IslandsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Max Area of Island Without Changing the GridFlexport · PHONE SCREENFlexport interview questions
  • Count Enclosed Freshwater RegionsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Count Connected IslandsUber · PHONE SCREENUber interview questions
  • Number of IslandsSpaceX · PHONE SCREENSpaceX interview questions
  • Count Islands in a Binary GridApple · PHONE SCREENApple interview questions
  • Pacific Atlantic Water FlowAnduril · PHONE SCREENAnduril interview questions
  • Grid Pathfinding with Obstacles (DFS)Roblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Number of IslandsGoldman Sachs · OA · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • House Bounds in a Ragged GridRippling · OA · PHONE SCREENRippling interview questions

Interview reports that mention this question

  • Adobe SDE and Senior SWE Interviews: 9 Experiences (Part 3 of 6)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public int[][] outlinePixels(int[][] image) {
        // Write your code here.
    }
}
Checking account…