ACloudFirm | OA | distinct digit numbers
Anonymous User
464

This is the first OA question from a firm that provides cloud service. However, I didn't manage to pass all test cases in time. I uesd Python and got 14/15 passed - the last test case TLE.

Here's the question -

Given an array of array that consist of number ranges (inclusive), print the count of numbers that have distinct digit numbers. Return nothing.
For example, [[1, 12], [30, 40]], we print 11 and then 10. we exclude 11 and 33.

Constraints
1 <= num <= 10^5
I forgot how long the array could be, but by seeing the test case it can be as long as 1000. so it should be -
1 <= len(arr) <= 1000

I tried kinda like brute force. I iterated over the input and get the overall lowerbound and upperbound, put all numbers that have duplicate digits in the set. And iterative over the input again check each number in the range, see if they are in set, and print out the overall count.
This solution still TLE. I guess if I use Java I may pass. However wondering if there's more optimized solution?

Comments (0)