left4dead
BAN USER
Comments (3)
Reputation 10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
1
of 1 vote
^counter argument for above suggestion:
The problem demands solution for "find all the patients who have at least the 3 problems from the set."
So if you create a 2D array, you can surely access required disease in O(1). However, while searching for one patient who has at least 3 diseases, you have to access all the disease columns in worst case. So for one patient, the time complexity in you DS will be O(m). Even though m is small, this seems a trivial solution. The time complexity in your case will be O(n x m) for all the patients. Please correct me if I am wrong.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
I didn't see all the codes posted but went through for some of them. My idea is simple. Just store 1st non-matching character/number in both provided numbers. This number will be our fault number which can not be pressed. If we find any other non-matching number and that number is also not matching to previous fault number, then it means there are more than two fault numbers which can not be true. So return.
- left4dead October 05, 2014