0 like 0 dislike
499 views
| 499 views

0 like 0 dislike

Recruiter contacted after application. Scheduled Phone Interview

During interview, the interviewer jumped straight to the question.

The question was not a direct one but after going through it I figured it out to be Confusing Number 2

First gave brute force solution for going through every number, checking if flipping it does it become a different number. If yes then add it to collection.

I myself suggested to the interviewer that this solution is not scalable. In the question I was given N from 1 to 650.

I suggested that only digits 0, 1, 6, 8, 9 can produce numbers that can generate confusing numbers.

Explained the complexity of this approach as I would have to go through much fewer numbers. (For example for 3 digit numbers it would be 4 * 5 * 5 i.e 100 numbers)

Wrote the code for it by generating all possiible combinations from these 5 numbers and checking for each whether it can be flipped or not.

Interviewer wanted to try a test case but I told him let me finish up the remaining code (the boilerplate stuff) While I was finishing up the code the interviewer was talking to himself "that ok you got this method and you got this method"

When finished up the code I asked the interviewer what test case he wanted to try and he told me that it works. He didn't give me a chance to run my code through some test cases as he jumped to a question.

He asked me how would you test your code ? I knew I hadn't handled the case for INT_MAX and told him straight up that it would crash for that input and he agreed.

I was a bit confused at this question as the input range was from 1 to 650 and it didn't click to me that basically hes asking that the my code should check whether number is positive or not.

My code had two parts as I said above "Generating Combinations" and "Flipping the number to check validity"

I told him that you could give a set of inputs of numbers containing 0, 1, 6, 8 ,9 only and another set containing 2,3,4,5,7,9 and a mix of numbers containing both. But he told me we can't do that as the combinations generating method just takes N.

Then he told me that N should be positive after some time. After that he told me that the other flip method can be checked using "WHITEBOX TESTING". I told him I didn't know what that is and he explained what it means. I told him that to test that method we could use the above approach as I suggested and he seemed to have agreed.

After that the interview ended.

Recruiter called couple of days later and said it was not recommended to move forward and couldn't give any feedback.

LC : 700+ (128 Hard, 360 Medium, 280 Easy, 2+ yrs of experience) Preparation of more than a year. Did many questions multiple times.
by Expert (30,360 points)