Question bank › Backtracking
Dsa Backtracking Medium

The 2xN Colorist

You are coloring a grid of size 2 rows and N columns. You have 3 colors: R, G, and B. No two adjacent cells (horizontally or vertically) can have the same color. Some cells are already pre-filled with a color, while others are empty ('.'). Count the number of ways to complete the coloring. Example: Input: 2 .R .. Output: 4 (Explanation: A 2x2 grid where (0,1) is Red. Valid colorings are limited by adjacency constraints.)

Key concepts

backtrackinggridcounting

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.