Tumblr interview: #Write a function for finding an ordered word pair occuring with the greatest frequency in a given string. For example # "I want to be a part of it, New York, New York." #"I want", "want to", "to be", "be a",... #And the most frequent is "New York". def frequency source="I want to be a part of it, New York, New York." source = source.gsub(",","") source = source.gsub(".","") list=source.split(' ') counts={}; prev="" list.each do |word| if prev !="" if counts[ "#{prev} #{word}" ] == NIL counts[ "#{prev} #{word}" ] =0 end counts[ "#{prev} #{word}" ] +=1 end prev=word end print counts print counts.sort{|a,b| a[1] <=> b[1]}.last end frequency 1) Assume the following sequence of bash commands. Explain what each does, whether it can fail, how it can fail > and explain the result. > > echo * > echo "*" > echo '*' > echo `*` > > mkdir a > cd a > touch b > ls > c > cat c 2) Given some bash commands how do you redirect to make a new file? And will the new file set show up? This will be asked if you fail to answer correctly to final line in 1) > > 3) "given two words write a function that returns true if the letters in one is a permutation of another". eg if two words are "abc" and "acd" it should return true. The answer involves sorting > 4) If you have a master and a number of standby slaves, describe the process to promote one of the slaves to a master safely allowing for the fact the just-failed master might come back online. > 5) Make sure you understand bash syntax '>' at a system level. What does it do? Write a c or perl program to emulate the process of using '>' in bash. > 6) Write a function that will linearly roll out a feature on a website over 24 hour period. user id 1 should be rolled out last. You are given the total number of users. Assume that this function will be used by a web application. Do not assume that all users will be visiting it during 24 hours period. > 7) If you have a large amount of servers and applications running on the servers, how can you aggregate/ roll out reshooting of the entire DB scheme? Can you write a function to do that? This problem I did not understand fully. Perhaps read up on tumblr's github "jetpants" code. Something like 'given N application servers and N aggregators that these application servers are writing distributively (e.g. aggregator 1 is responsible for keys starting with A and aggregator 2 is for B and C) give a strategy to rebalance the keyspace when a new aggregator is added. You can assume that the app servers have local caches. Strategy must not use time or puppet. > 8) What do you think of XYZ technology? What is your opinion etc? These are the ones I can recall. They were similar to the test questions you sent. Hope they’ll be helpful to the other candidates ========================= Find all anagrams (a) in the list (s) of any given word (c) s={"rodo","rood", "odor", "desk", ...} c={"door"} a={"rood", "rodo", "odor”} Solution: Sort characters of each array item in (s) and compare it to the sorted characters in (c) ========================= Given a sequential list of user_ids, a start and stop time, and assuming a consistent rollout rate, write a function to determine whether the feature is currently enabled for a given user_id. Solution: Map user_ids to the exact second each user_id is supposed to receive the feature, compare requested user_id with the map ========================= The rest were about my experience with databases, CDNs and server optimization.