You are on page 1of 10

Interview Questions I was asked by a "Big 4" internship : cscareerquestions

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

Please read the FAQ and search before asking a search


new question
29

Interview Questions I was asked by a "Big


4" internship (self.cscareerquestions)
submitted 8 hours ago by critiqueMePls

this post was submitted on 30 Jan 2015

29 points (87% upvoted)


shortlink: http://redd.it/2u5ct3

Just had an interview with a Big 4


Here are some of the questions they asked.
Would love to see your implementation /
technique.
1) Given a huge string of letters, you must
return the total times each letter appeared in an
array in the format "@#" where @ is the letter
and # is the number of times that letter
appears. Ex: Given "aaabbcccd" you must
return [a3,b2,c3,d1,e0,f0,...,y0,z0]
2)Given 2 sorted arrays. Merge them together
such that they are sorted when merged. No
O(n2) runtime.
3)How to look through all the pixels in a picture
and store there RGB value efficiently.
55 comments

share save

hide give gold report

all 55 comments
sorted by: best

Ask a new question

cscareerquestions
unsubscribe

36,737 readers

~83 users here now


Show my flair on this subreddit. It looks like:
wonderful_wonton (edit)

This subreddit is responsible for answering


questions about careers in Computer Science,
Computer Engineering, Software Engineering,
and other related fields. Respect the reddiquette,
and reserve this space for questions concerning
careers and degrees only. Please keep the
conversation professional.

Contribute to the FAQ!


Current Resume/Interview Advice Thread
Current Internship Advice Thread
A subreddit for IT career questions
A subreddit for general programming discussions
reddiquette
A subreddit purely for coding discussions

save
[] ohmygoshitsjosh 17 points 7 hours ago*

A subreddit for CS theory


A subreddit for CS education

1. There is a good number ways to do this. We


A subreddit for telecommuting
could simply use a hashmap with a letter,
A subreddit for general job stuff
frequency pair. O(n) runtime/space. If the
interviewer wants access to the most frequent Don't see your link?
http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/

Page 1 of 10

Interview Questions I was asked by a "Big 4" internship : cscareerquestions

1/30/15, 5:01 AM

element at all times, then we could use an AVL


tree or a heap. Also, if we only care about
letters, we could initialize an array of ints and
increment by index.

created by [deleted]

a community for 3 years

2. Not sure how one would get O(n2) to begin


with, but you'd initialize an array of size n+m,
then have a pointer at the beginning of both.
For each insertion, check which pointer has
the greater value, update that one and insert
the one unchanged. runtime O(n+m).
3. If I understand you correctly, you can just
make one large list of triplets holding each
RGB value. So indexing into the matrix would
give you the triplet. There could be some other
discuss this ad on reddit
way relating to data compression that I'm
unaware of, however.
MODERATORS
message the moderators
Might I ask what year you are? I've interviewed with InCaseOfEmergency
alanbot
3 of the big 4 companies and the questions I've
Chris911
experienced are of orders of magnitude more
CriticDanger Software Engineer
difficult. Not trying to be mean, just genuinely
about moderation team
curious.
permalink

save report

give gold

RECENTLY VIEWED LINKS

reply

[] babypandaa 8 points 6 hours ago

I agree with you. From what I have


experienced/heard of, these are relatively
simple. Not to say these are bad questions, or to
sound egotistical.
permalink

save parent

report

give gold

reply

[] RedAlert2 10 points 5 hours ago

#3 isn't that simple if you really dive into it.


You could do a thesis on lossless image
compression.
permalink

save parent

report

give gold

reply

Interview Questions I was asked by a


"Big 4" internship
29 points | 55 comments

[#46|+2853|1430] ELI5: Why have I


learned so much about the Holocaust
and the war crimes committed by the
Nazis, but I have never learned anything
about the Japanese war crimes during
WWII? [/r/explainlikeimfive]
101 points | 14 comments

This is how you pack a UPS truck


4488 points | 1018 comments

My Dad and I share a name


3026 points | 263 comments

[] UlyssesSKrunk 3 points 4 hours ago

It's basically 1 level deeper than fizzbuzz.

My friend's craftsmanship is amazing

permalink

2379 points | 111 comments

save parent

report

give gold

reply

clear

[] oeq_ 1 point 22 minutes ago

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

Interview Questions I was asked by a "Big 4" internship : cscareerquestions

permalink

save parent

report

1/30/15, 5:01 AM

give gold

reply

[] critiqueMePls [S] 5 points 4 hours ago*

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

[] valakut_ 4 points 3 hours ago

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

[] CViper 2 points an hour ago

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

2 points 3 hours ago

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

[] narett 1 point 3 hours ago

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

Interview Questions I was asked by a "Big 4" internship : cscareerquestions

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

[] readytogetstarted 1 point 11 minutes ago

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

[] WatchDaThrone 6 points 4 hours ago

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

[] voiderest 14 points 4 hours ago

You should probably be worried if you can't come up with at least correct answer for 1 and
2.
permalink

save parent

report

[] s32 Software Engineer

give gold

reply

1 point an hour ago

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

[] bro_montana 7 points 4 hours ago

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

[] daaasb 2 points 4 hours ago

The first two are actually pretty easy.


permalink

save parent

report

give gold

reply

[] _RPM 1 point 4 hours ago

the easiest question is the first. they get increasingly difficult. what university did you go
to?
permalink

save parent

report

give gold

reply

[] alpha_squared 2 points 3 hours ago

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

Interview Questions I was asked by a "Big 4" internship : cscareerquestions

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

[] antisyzygy Data Scientist

give gold

reply

1 point an hour ago*

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

[] alpha_squared 1 point an hour ago

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

[] Quixotic_Fool 1 point 8 minutes ago

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

[] nsq0 6 points 6 hours ago

from collections import Counter


from string import lowercase

http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/

Page 5 of 10

Interview Questions I was asked by a "Big 4" internship : cscareerquestions

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

[] droogans 10 points 6 hours ago

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

[] nsq0 3 points 4 hours ago

Haha thanks (Python master race)


permalink

save parent

report

give gold

reply

[] valakut_ 1 point 3 hours ago

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

[] poreddit 3 points 6 hours ago

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

[] lxa478 4 points 5 hours ago

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

[] kcc989 Software Engineer

give gold

reply

2 points 4 hours ago

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

[] Waistcoat 1 point 4 hours ago

http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/

Page 6 of 10

Interview Questions I was asked by a "Big 4" internship : cscareerquestions

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

[] darksounds 1 point 58 minutes ago

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

[] bcguy390 Software Engineer

report

give gold

reply

5 points 8 hours ago

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

[] dlp211 9 points 7 hours ago

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

[+] Taurath comment score below threshold (2 children)


[] Thounumber1 5 points 7 hours ago

Which big4 was this, may I ask?


permalink

save report

give gold

reply

[] critiqueMePls [S] 3 points 4 hours ago

Microsoft
permalink

save parent

report

give gold

reply

[] Thounumber1 2 points 4 hours ago

was this for a FT position or internship? Also what university>?


permalink

save parent

report

give gold

reply

[] bro_montana -4 points 4 hours ago

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

[] -SnowMan- 4 points 1 hour ago

Umm... Microsoft, Amazon, Google and Facebook? Am I missing one?


http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/

Page 7 of 10

Interview Questions I was asked by a "Big 4" internship : cscareerquestions

permalink

save parent

report

give gold

1/30/15, 5:01 AM

reply

[] Lkinash 1 point 1 hour ago

Apple?
permalink

save parent

report

give gold

reply

[] redditthrowaway1995 1 point 56 minutes ago

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

[] Seeeejaaaay 0 points 5 hours ago

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

[] Recolumn 3 points 6 hours ago

3) http://stackoverflow.com/a/4801397
That's the most efficient way I can think.
permalink

save report

give gold

reply

[] omeganemesis28 Graduate Student

1 point 4 hours ago*

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

[] MrVonBuren 3 points 5 hours ago

#1 in awk:

AirBoxOmega:~ d$ awk '{split($0,a,"");for (i in a){letter[tolower(a[i])]++}};END{fo


d,145
e,414
f,58
g,71
h,88
i,213
j,7
k,7

http://www.reddit.com/r/cscareerquestions/comments/2u5ct3/interview_questions_i_was_asked_by_a_big_4/

Page 8 of 10

Interview Questions I was asked by a "Big 4" internship : cscareerquestions

1/30/15, 5:01 AM

l,126
m,76
content of /tmp/str
permalink

save report

give gold

reply

[] Frenchiie 1 point 6 hours ago

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

[] what_is_thiss 2 points 2 hours ago

What type of position were you applying for?


permalink

save report

give gold

reply

[] _RPM 1 point 4 hours ago

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

[] alpha_squared 1 point 3 hours ago

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

[] paladine01 Software Engineer

give gold

reply

1 point 4 hours ago

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

[] _RPM 0 points 4 hours ago

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

[] rhashish1 2 points 4 hours ago

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

Interview Questions I was asked by a "Big 4" internship : cscareerquestions

1/30/15, 5:01 AM

table[97] = 5 would resolve to a5


If you only have to handle lowercase ASCII, you can use an int[26] and simply subtract
97 from the ASCII value of the letter to find the array index, increment the value by 1,
and add 97 to the index before outputting it.
permalink

save parent

report

give gold

reply

[] alpha_squared 4 points 3 hours ago

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

[] voiderest 1 point 4 hours ago

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

You might also like