Asana · Data Structures & Algorithms
Implement core puzzle/array/grid routines
TrueInterview
October 7, 2026 · 1 min read
You may need to complete one or more of the coding exercises below (produce clean, testable code; explain the time and space complexity):
- Jigsaw assembly (small backtracking)
- You receive
Nsquare tiles. Every tile carries four edge labels:top,right,bottom, andleft(all strings). Two tiles placed next to each other are compatible when their touching edges share the same label. - A tile can be rotated by 0, 90, 180, or 270 degrees, which rearranges its edge labels.
- Given integers
RandCwithR*C == N, decide if the tiles can be placed in anR x Cgrid such that all internal adjacent edges match. (Optionally, also return one valid arrangement of tile IDs and rotations.) - Assume
Nis small enough to permit backtracking (for example,N <= 12).
- ASCII canvas printer
- Build an ASCII drawing engine whose blank canvas is
H x Wand initially filled with spaces. - You will be given a list of drawing commands, including:
RECT x y width height ch(paint the rectangle with characterch)HLINE x1 x2 y ch(draw a horizontal line)VLINE x y1 y2 ch(draw a vertical line)
- Commands that come later overwrite earlier output.
- Print the final canvas as
Hlines, each containingWcharacters.
- Product of array except self
- Given an integer array
numsof lengthn, return an arrayoutin whichout[i]is the product of allnums[j]wherej != i. - Division is not allowed.
- Aim for
O(n)time; aside from the output array, extra space should beO(1).
- 2048 move simulation
- Given a
4 x 4grid of non-negative integers (powers of two or zero) and a direction chosen from{left, right, up, down}:- Move every tile as far as possible in that direction.
- Merge equal adjacent tiles only once per move (for example,
2 2 2 0moved left becomes4 2 0 0, not8 0 0 0).
- Return the updated grid (optionally, also return the score gained from merges).
Overview: This question set tests algorithmic problem-solving abilities, including backtracking and constraint satisfaction for jigsaw assembly, simulation and state manipulation for ASCII canvas and 2048 move logic, and linear-time in-place array transformation for the product-of-array problem.
Loading comments…