Interview Question for Software Developers


Country: India
Interview Type: Phone Interview




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

Typo in the explanation, minimum time taken is 2 minutes.

- viksvampire19 December 03, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I didn't get the answer for this. Has anyone has any idea?

- Avinash December 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Akshay's solution fails for the test case
2 2
1
5

for which your code's output will be 5 but optimised output is 2 since the 1st cab can finish the second trip in 2nd minute

- untamable December 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

{{static int minTime(int n, int k, List<Integer> timeArr) {
int[] tasksArr = new int[k];
timeArr.sort(Comparator.naturalOrder());

for (int i = 0; i < k; i++) {
tasksArr[i] = 1;
n--;
}

while (n > 0) {
int smallest = Integer.MAX_VALUE;
int whoIsDoneIndex = -1;
for (int i = 0; i < k; i++) {
if (tasksArr[i] * timeArr.get(i) < smallest) {
smallest = tasksArr[i] * timeArr.get(i);
whoIsDoneIndex = i;
}

}

tasksArr[whoIsDoneIndex] = tasksArr[whoIsDoneIndex] + 1;
n--;
}

int maxValue = Integer.MIN_VALUE;
for (int i = 0; i < k; i++) {
maxValue = Math.max(maxValue, tasksArr[i] * timeArr.get(i));
}

return maxValue;
}
}}

- Akshay December 05, 2017 | Flag Reply


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