Company: PhonePe

Difficulty: medium

Problem Statement

Nth Number Avoiding Forbidden Digits Problem Description A payments platform stamps every settlement with a positive integer reference number. The operations team has blacklisted some decimal digits: a reference number is valid only if none of the blacklisted digits appears anywhere in its decimal representation. Reference numbers are written in the usual way, without leading zeros. You are given D forbidden digits. Consider every valid positive integer, listed in increasing order. Your task is to report the N -th number in that list. Input Format The first line contains a single integer D — how many digits are forbidden. The second line contains D space-separated distinct digits. When D = 0 this line is empty. The third line contains a single integer N . Output Format Print one line containing the N -th smallest valid positive integer. Constraints 0 <= D <= 8 0 <= each forbidden digit <= 9, and the D digits are pairwise distinct 1 <= N <= 10^9 Since at most 8 d

More PhonePe OA questionsInterview experiences