Understand the jigsaw puzzle problem and learn the questions to simplify this problem.

We'll cover the following

## Problem definition

A jigsaw puzzle is a picture divided into irregularly shaped pieces that can be assembled together to form a complete picture. A puzzle has a fixed number of pieces that can only fit together in exactly one way. We can solve the jigsaw puzzle by aligning the pieces in a way that they fit with each other and also create a coherent picture.

## Expectations from the interviewee

Although the jigsaw problem is a simpler design problem asked in interviews, the interviewer still has some expectations. The following provides an overview of what the interviewer wants to hear you discuss in more detail during the interview.

### The puzzle board

You may want to ask the interviewer more about the kind of jigsaw puzzle. You can ask the following questions:

• What does a jigsaw puzzle look like. Is there a picture or a pattern on the puzzle?

• What type of shape does our board have? Is it rectangular, circular, or any other shape?

### The puzzle pieces

It is important to clarify the requirements for a single piece of the puzzle as it is a key feature of the problem. You can ask the following questions:

• What kind of shape do the puzzle pieces have? How many sides does a piece have?

• How do the pieces fit together?

• Will all the pieces of a jigsaw puzzle be unique?

## Design approach

We are going to design this jigsaw puzzle using the bottom-up design approach. For this, we will follow the steps below:

• Identify and design the smallest components first like the puzzle edges of a piece.

• Use these small components to design bigger components, for example, the puzzle piece.

• Repeat the steps above until we design the whole system, i.e., the puzzle board.

## Design patternĀ

During an interview, it is always a good practice to discuss the design patterns that a Jigsaw puzzle falls under. Stating the design patterns gives the interviewer a positive impression and shows that the interviewee is well-versed in the advanced concepts of object-oriented design.

Try to answer the following question. If you are not familiar with design patterns, donāt worry! You can learn about them by asking questions like, āDefine design patterns.ā