Question bank › Backtracking
Dsa Backtracking Medium

Coloring Boards

Given a board of N cells arranged in a single row, implement a function that colors the cells using K different colors such that no two adjacent cells have the same color. Your task is to count the number of valid ways to color the board. Input format: - The first line contains an integer N (1 <= N <= 20), the number of cells. - The second line contains an integer K (1 <= K <= 10), the number of colors available. Output format: - Print a single integer which is the count of valid colorings of the board. Example: Input: 3 2 Output: 6

Key concepts

backtrackingcombinatorialarray

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.