Toppr Interview Question for Software Engineer / Developers


Country: India
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
0
of 0 vote

Use KD BST tree for storing these events and perform the range search. It gurantees to be O(nlogn) times in worst case can go upto n.

- Deep October 10, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sort by start date, probably into a multimap. Than one more path is enough to mark overlaps.

- Arkadi October 10, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What about creating an arrany of "int Day[30]". Initialize with zero. Increment the value at each index once a date a found on that day.

- Unknown October 10, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Create a binary search tree which stores the end points of each time interval. Each node should also store what time interval its value comes from.

Notation: dates are represented in MMDD format.
Nodes: (1010, 0), (1015, [0, 2]), (1012, 1), (1014, 1), (1024, 2), (1023, 3), (1103, 3), (1004, 4), (1005, 5).

After constructing this BST, for each time interval, perform a search looking for a value that is contained in the given interval AND does not belong to the given interval. These searches should be directed towards branches that may lead to time conflicts, i.e. if we got the interval [1015, 1024] and we face a node with value 1010, naturally we need to conduct the search to the branch in the right.

Assuming that we have the ability to create a balanced BST, the construction phase is O(nlogn) and the search phase is also O(nlogn).

- Victor October 11, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

While my solution seems to work for this problem, it is not correct for the general case (in which you pick just one interval and wants to get the conflicts for it). This is because my algorithm doesn't cover the case where an interval completely contains another one, e.g. [1000, 1005] and [1001, 1004].

Thus, you'd better use Interval Trees, which are 100% correct.

- Victor October 11, 2014 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More