KevinDeBruyne17's blog

By KevinDeBruyne17, history, 7 weeks ago, In English

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

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

In your first statement, you are talking about integers while, in the end, it says "digits". Which one is correct?

»
7 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by KevinDeBruyne17 (previous revision, new revision, compare).

»
7 weeks ago, # |
  Vote: I like it +16 Vote: I do not like it

Is this problem really solvable? A valid input is {[100, 999], [100, 999], ..., [100, 999]} for 100 intervals which has an absurd number of answers that can't be printed in any reasonable amount of time.