New grad software engineer Interview Questions | Glassdoor

New grad software engineer Interview Questions

642

new grad software engineer interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

Write a function that finds the median of a set of three numbers, also find the Big O. Can it be done with only 2 comparisons, or do you need 3?

11 Answers

Pick two numbers: A and B, Add the third number to each of the first two : (A+C), (B+C). Compare these two numbers and take the lesser of the two. Now compare C with the other member of the less number. The greater of these two is the median.

I'm not following. Is this: say, B+C is less than A+C, then the larger of B and C is the median? If so, isn't this a counterexample: A = 2, B = 1, C = 3?

Actually the answer is the next one: we could have an answer using only two comparisons. The main idea is that we need to examine one of the numbers to get into the segment created by the other two numbers. And another important thing is that one comparison could be used to definitely determine for both two segments created by two numbers. For example we are trying to examine number A and we have two segments formed by B and C numbers: [B; C] and [C; B]. But considering that for determining if A is in the segment created by B an C we need to make the following comparison: (A - B) * (C - A) >= 0. It is easy to notice that if A is in segment [B; C] (B is less or equals to C) we have both multipliers are positive but in an opposite case when A is in segment [C; B] (C is less or equals to B) we have both that multipliers are negative. If former comparison is negative - then number A is not in any of segments [B; C] or [C; B]. And here is a code of function on C/C++: int medianOfThreeNums(int A, int B, int C){ if ((A - B) * (C - A) >= 0) { return A; } else if ((B - A) * (C - B) >= 0) { return B; } else { return C; } }

Improve this piece of code, loop tracing, very basic printing problem

10 Answers

Given a base 10 number, print the hexidecimal (base 16) representation of that number.

7 Answers

We have a fairly large log file, about 5GB. Each line of the log file contains an url which a user has visited on our site. We want to figure out what's the most popular 100 urls visited by our users.

6 Answers

He asked me to write a function to detect whether string1 contains all letters in string2

4 Answers

If you had a savings account with $1, at a 100% interest rate, at what year would you have 15 billion dollars?

4 Answers

Given a bug report of a common Python library (everyone would know this library), run tests to observe the issue and then fix it.

5 Answers

Write a function that takes in an integer and returns the number of ones set in the binary representation.

5 Answers

Write an algorithm to print out all of the possible solutions for a^3 + b^3 = c^3 + d^3

3 Answers

Given a list of integers of at least length 7, print the average of each consecutive 7 number long subsequence (sliding window).

4 Answers
110 of 642 Interview Questions