Professional Documents
Culture Documents
MY SUBREDDITS
1/30/15, 5:01 AM
FRONT - ALL - RANDOM - FRIENDS | ADVICEANIMALS - PICS - VIDEOS - ASKREDDIT - INTERESTINGASFUCK - EXPLAINLIKEIMFIVE
EDIT
CSCAREERQUESTIONS
comments
related
wonderful_wonton (728) |
| preferences | logout
share save
all 55 comments
sorted by: best
cscareerquestions
unsubscribe
36,737 readers
save
[] ohmygoshitsjosh 17 points 7 hours ago*
Page 1 of 10
1/30/15, 5:01 AM
created by [deleted]
save report
give gold
reply
save parent
report
give gold
reply
save parent
report
give gold
reply
permalink
save parent
report
give gold
reply
clear
I dunno, these questions sounded vomitinducingly difficult to me. Maybe I'm just
not smart enough.
http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/
account activity
Page 2 of 10
permalink
save parent
report
1/30/15, 5:01 AM
give gold
reply
We didn't need to access the list to modify it in anyway after the initial count. I really like
your increment by index solution though.
None taken. I'm in third year CE at a target school. Usually 300+ students apply to these
postings on the job board. So the big 4 and other companies usually have a general basic
tests to weed people out. Then the other two rounds is where you get deal with the fun
stuff.
Edit: It was a timed hour test with 3 more questions. If you're interested, there is a grid of
size n x m. On this grid there exists a dog, a bin, and multiple balls scattered throughout
the grid. You are given the dogs and trees starting location and the locations of all the nuts.
Dog can only carry one ball and cant move diagonal. Find the least number of transitions
for it to collect all the balls and return it to the bin.
permalink
save parent
report
give gold
reply
You are given the dogs and trees starting location and the locations of all the nuts.
Nuts? I assume you meant balls there?
Anyway, represent the n x m grid as an undirected graph with n * m nodes. Add edges
with cost 1 between two nodes if you can move from one node to the other. Run
Breadth First Search starting from each ball and ending at the bin. This gives you the
shortest distance between the ball and the bin. Each ball except 1 (the first ball you go
to) costs at least twice its min distance to the bin. Now, run BFS starting from the
starting location of the dog to compute the shortest distance between the dog and each
ball. Greedily choose the ball minimizes (distance between ball and dog) - (distance
between ball and bin). Sum up all the distances and there's your solution.
permalink
save parent
report
give gold
reply
I'm just wondering if you ever learned about merge sort in one of your classes? When I
saw #2 it became obvious since merge sort includes the solution in the algorithm.
permalink
save parent
[] naht_a_cop Student
report
give gold
reply
For the first one, could you get the ASCII value of it, mod 26, and +=1 that index value?
Essentially a hashmap, but a little simpler.
permalink
save parent
report
give gold
reply
It's pretty awful I can't answer any of these or understand these answers. I've tried
learning algorithms and data structures, but I always ended up trying to memorize them
instead. What I lacked was a practical use for them since nothing I ever did or made
required knowledge like what's being discussed in this thread.
http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/
Page 3 of 10
1/30/15, 5:01 AM
What can I do to learn data structures and algorithms to the level where I can perform well
in these kinds of interviews? Also, what can I do to not only learn them, but to understand
both?
As you can probably tell, I'm not in school (anymore).
permalink
save parent
report
give gold
reply
read algorithm design manual. do the uva online judge exercises that it suggests in the
exercises of each chapter.
permalink
save parent
report
give gold
reply
I graduated with a CS degree from a pretty good university and a 3.5 GPA and I am not able to
answer any of these questions, not even slightly, is that a problem? Or are these just difficult
questions?
permalink
save report
give gold
reply
You should probably be worried if you can't come up with at least correct answer for 1 and
2.
permalink
save parent
report
give gold
reply
Yeah, I interview for a big4. Those would be warm up questions just to ensure that the
candidate is able to solve a relatively basic problem.
permalink
save parent
report
give gold
reply
If you are trying to get a Software Engineering position at a top tier company then yes.
Otherwise not particularly. But as far as algorithmic questions go these are fairly simple.
You will find if you review your data structures and algorithms material and do some
practicing, they're not as hard as they look at first.
permalink
save parent
report
give gold
reply
save parent
report
give gold
reply
the easiest question is the first. they get increasingly difficult. what university did you go
to?
permalink
save parent
report
give gold
reply
The first one is easy to solve if you know your data structures and the second is easy if you
understand algorithms a bit.
The third can actually be difficult depending on how you approach it, but since this is an
http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/
Page 4 of 10
1/30/15, 5:01 AM
internship level then it's probably meant to see how you reason through solving it.
In short, yes, you should be worried if you don't at least have an idea on where to start.
Your situation, and I certainly don't mean any offense, is why I don't place much value in
school/GPA because it doesn't speak at all to someone's abilities. I graduated in CS a
month ago from an okay school with a 2.2 GPA and I knew exactly how to solve 1 & 2 after
I finished reading the questions and I certainly don't consider myself an above average
software engineer.
permalink
save parent
report
give gold
reply
Your situation, and I certainly don't mean any offense, is why I don't place much
value in school/GPA because it doesn't speak at all to someone's abilities.
I agree, but among college educated people you'll find a higher percentage of qualified
people to unqualified people.
I knew exactly how to solve 1 & 2 after I finished reading the questions and I
certainly don't consider myself an above average software engineer.
That's actually good. It means you are entering the pit of the Dunning-Kruger effect
curve, so on to the path of true knowledge. I.e. the more you learn the more you
realize how little you know. I have a MS in Mathematics with good grades, I get paid
well by other people to do what I learned, and I still feel like a charlatan half the time
because I find out I don't know/remember something I probably should have
known/remembered.
permalink
save parent
report
give gold
reply
I agree, but among college educated people you'll find a higher percentage of
qualified people to unqualified people.
That's probably true.
the more you learn the more you realize how little you know
I realize I know little-to-nothing, does that mean I really just know everything? :D
permalink
save parent
report
give gold
reply
This is a severe problem. The first two are extremely trivial, the last question isn't actually
very clear.
permalink
save parent
report
give gold
reply
http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/
Page 5 of 10
1/30/15, 5:01 AM
def get_counter(s):
ctr = Counter(s)
return [c + str(ctr[c]) for c in lowercase]
def merge(lst0, lst1):
return sorted(lst0 + lst1)
permalink
save report
give gold
reply
I love how many answers here revolve around using no tools except the essential
constructs of a Turing complete language, and yet Python ships these as two and three line
methods from the built ins.
I'd hire you.
permalink
save parent
report
give gold
reply
save parent
report
give gold
reply
The best one is transposing a matrix in 1 line of code without any imports
(http://norvig.com/python-iaq.html):
>>> m = [(1,2,3), (4,5,6)]
>>> zip(*m)
[(1, 4), (2, 5), (3, 6)]
permalink
save parent
report
give gold
reply
How would most interviewers react to a solution like this? Obviously it shows your mastery
of Python but don't they want to see knowledge of general algorithms?
permalink
save parent
report
give gold
reply
I just got asked the count letters question in an interview. I gave them the Python
solution first. We all laughed and they said that was clearly the "right" answer, but to
give them the answer using general programming concepts/algorithms. They did
appreciate that I knew thy Python solution though.
permalink
save parent
report
give gold
reply
Not Big 4, but I've had plenty of interviews where they are just as interested in my
mastery of my chosen language as my mastery of algorithms.
permalink
save parent
report
give gold
reply
http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/
Page 6 of 10
1/30/15, 5:01 AM
I feel like if you could explain why these are both O(n) you'd cover both python and
algorithms knowledge.
permalink
save parent
report
give gold
reply
If you know the python but can't explain why it fits in the complexity bounds, the
interviewer wouldn't like it that much.
permalink
save parent
report
give gold
reply
1.) Use hashtable to store each occurrence of character. Then go through hashtable to print out
each # of times. O(N)
2.)Have 2 pointers to beginning of array, compare the pointers for smaller value, place into
new/final array increment pointer. Repeat until one is at an end, then append the rest.
O(N+M), N+M = size of both arrays
3.) Not 100% what you mean, but I would create an pixel object with properties int r, int g, int
b.
permalink
save report
give gold
reply
For the first one, assuming the string is in ASCII, a true hashmap is overkill. Just use an
array of 26 ints and then increment based on the index calculations for that particular
letter.
Getting the values out of the array will be faster than a traditional hashmap as well.
permalink
save parent
report
give gold
reply
save report
give gold
reply
Microsoft
permalink
save parent
report
give gold
reply
save parent
report
give gold
reply
I'm guessing you're leaving out Amazon if you are considering Microsoft in the big 4?
What's your perception of them?
permalink
save parent
report
give gold
reply
Page 7 of 10
permalink
save parent
report
give gold
1/30/15, 5:01 AM
reply
Apple?
permalink
save parent
report
give gold
reply
Apple, probably. The problem with the big four is that there are actually five or
six companies in the big four.
permalink
save parent
report
give gold
reply
Well OP lives in Waterloo and I know Google has an office there so my guess is Google.
permalink
save parent
report
give gold
reply
3) http://stackoverflow.com/a/4801397
That's the most efficient way I can think.
permalink
save report
give gold
reply
yeah, its definitely a bitmasking question. That is the most efficient solution.
To further answer the question, that would be a 2D array (matrix) of integers (say
collection B). The original picture is collection A.
Each i,j integer in collection B represents the RGB in collection A at i,j respectively.
The RGB value from i,j in collection A is stored & masked to the int value in collection B at
i,j.
If you want to impress them further, you make collection B a 1D array as that increases the
efficiency should you ever traverse collection B linearly. But that isn't what they're asking
specifically for and is something you leave open for after identifying/implementing the
original solution and they ask for improvements.
permalink
save parent
report
give gold
reply
#1 in awk:
http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/
Page 8 of 10
1/30/15, 5:01 AM
l,126
m,76
content of /tmp/str
permalink
save report
give gold
reply
I'm surprised something like #3 was asked. I'm not really sure myself how to go about solving
something like that. Would this be specific to a language's API?
permalink
save report
give gold
reply
save report
give gold
reply
My immediate thought for 1. is to create a hash table. insert to hash table on each character.
the key would be the char, the value would intially 1. if present. increment it's value.
2.) they don't want you to use an inner for loop. so you're going to have to compare the
current value to a value in the second array via a constant lookup by index. (hopefully the two
arrays are the same length, else you're going to have to do some checks).
3.) I don't know anything about computer graphics.
permalink
save report
give gold
reply
You don't need to know anything about computer graphics. It seems like it's a problem
designed to test how you approach solving a problem that is likely outside of your scope.
permalink
save parent
report
give gold
reply
What's with people suggesting to use a hash table for #1? Just use an array and avoid the
overhead of hashing.
int table[255]; ....
permalink
save report
give gold
reply
If you use an array you can't store the value. ( the value being the number of times the
char exists) you might be thinking of maps in particular. in high level languages, an "array"
is usually a hybrid between a map and an actually array.
With int table[255]; where are you going to the store the number of times the character
has been seen?
permalink
save parent
report
give gold
reply
If the solution only needs to handle ASCII characters, you can simply use the ASCII
decimal values as the array index.
http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/
Page 9 of 10
1/30/15, 5:01 AM
save parent
report
give gold
reply
This is true, but now the assumption of ASCII needs to be stated before saying that
it is a "correct solution". A hash table doesn't make that assumption.
permalink
save parent
report
give gold
reply
1. The output looks like you are suppose to assume the letters are known beforehand so no
crazy unicode. With that you could just use an array to keep the count and just step
through the string once. While moving through the string you'd have to check for the char
being a letter upper or lower. A map might be easier to deal with which letter is being
counted as you'd check for an existing key and just increment the value.
2. Merge sort. Ideally using just the merging part of the algorithm once. Not just putting
them together and then sorting.
3. No idea.
permalink
save report
give gold
reply
about
help
tools
<3
blog
about
team
source code
advertise
jobs
wiki
FAQ
reddiquette
rules
contact us
mobile
firefox extension
chrome extension
buttons
widget
reddit gold
store
redditgifts
reddit AMA app
reddit.tv
radio reddit
Use of this site constitutes acceptance of our User Agreement (updated) and Privacy Policy (updated). 2015 reddit inc. All rights reserved.
REDDIT and the ALIEN Logo are registered trademarks of reddit inc.
http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/
Page 10 of 10