Print all unique integers made by concatenating one number from each range

Revision en2, by KevinDeBruyne17, 2021-08-05 14:57:25

Statement: Given a vector of ranges of the form [L,R] (L,R > 0). We have to print all unique integers that can be formed by concatenating integers taking one at a time from each of such ranges.

Constraints: Size of vector of ranges ~ 100

R - L <= 1000

Sample Example: Given vector: <[2,4], [3,5]>

Output: 23,24,25,33,34,35,43,44,45

This was one of the question that I was asked in an interview. I could only give a recursion based approach to this, where I checked for every integer in every range. Can someone help me with a more optimised approach for this

#### History

Revisions

Rev. Lang. By When Δ Comment
en2 KevinDeBruyne17 2021-08-05 14:57:25 9 Tiny change: 'for every digit in every ' -> 'for every integer in every '
en1 KevinDeBruyne17 2021-08-05 14:08:59 691 Initial revision (published)