Question bank › Recursion
Dsa Recursion Easy

Combinatorial Lock

You are tasked with designing a combinatorial lock with a specified number of digits. Each digit can range from 0 to 9. Write a program to find all possible combinations of the lock for a given number of digits. Your program should read an integer N from the input, which represents the number of digits in the lock, and then print all valid combinations in ascending order, each on a new line. Example Input: 2 Example Output: 00 01 02 03 04 05 06 07 08 09 10 11 12 ... up to 99.

Key concepts

recursioncombinatoricsbacktracking

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.