PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Asana

Solve a Jigsaw Puzzle

Last updated: May 10, 2026

Quick Overview

This question evaluates algorithm design and problem-solving skills related to combinatorial arrangement and constraint satisfaction, including spatial reasoning, edge-matching logic, and handling piece orientation.

  • medium
  • Asana
  • Coding & Algorithms
  • Software Engineer

Solve a Jigsaw Puzzle

Company: Asana

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given a collection of jigsaw puzzle pieces. Each piece has four edges: top, right, bottom, and left. A helper function `match(edgeA, edgeB)` is provided; it returns `true` if two edges can be connected and `false` otherwise. The puzzle is known to form one complete rectangular grid, but the number of rows and columns is not given. Pieces may need to be rotated. Implement a `solve(pieces)` function that returns a valid rectangular arrangement of all pieces, including each piece's orientation, such that every horizontally or vertically adjacent pair of edges matches according to `match`. You may assume: - Every piece must be used exactly once. - A valid solution exists. - The puzzle has no missing pieces. - Border edges do not need to match anything outside the puzzle. Discuss the algorithm, data structures, and time and space complexity.

Quick Answer: This question evaluates algorithm design and problem-solving skills related to combinatorial arrangement and constraint satisfaction, including spatial reasoning, edge-matching logic, and handling piece orientation.

Related Interview Questions

  • Compute Products Excluding Each Index - Asana (medium)
  • Implement an ASCII Art Printer - Asana (medium)
  • Implement ASCII canvas and solve two data problems - Asana (medium)
  • Implement core puzzle/array/grid routines - Asana (medium)
Asana logo
Asana
Apr 2, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0

You are given a collection of jigsaw puzzle pieces. Each piece has four edges: top, right, bottom, and left. A helper function match(edgeA, edgeB) is provided; it returns true if two edges can be connected and false otherwise.

The puzzle is known to form one complete rectangular grid, but the number of rows and columns is not given. Pieces may need to be rotated. Implement a solve(pieces) function that returns a valid rectangular arrangement of all pieces, including each piece's orientation, such that every horizontally or vertically adjacent pair of edges matches according to match.

You may assume:

  • Every piece must be used exactly once.
  • A valid solution exists.
  • The puzzle has no missing pieces.
  • Border edges do not need to match anything outside the puzzle.

Discuss the algorithm, data structures, and time and space complexity.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Asana•More Software Engineer•Asana Software Engineer•Asana Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.