Hope you’re having an awesome day! Here’s your interview problem and industry news.
Daily Interview Problem
You’re given an array of strings as input. The strings will only contain lowercase letters from
a-z. Group all the anagrams in the array together and return the resulting array. An anagram is a word that can be formed by rearranging the letters of another word.
Input: [“yx“, “abe”, “act”, “eab”, “x“, “eba“, “tca“, “xy“]
[“abe”, “eab”, “eba”],
Epic goes to war with Apple - Epic Games (creators of Fortnite and Unreal Engine) has filed a lawsuit against Apple following Apple’s removal of Fortnite from the iOS App Store. They also made this video mocking Apple’s 1984 commercial. You’ve gotta check the video out!
Airbnb still plans to IPO, despite 67% drop in Quarterly Revenue - Airbnb had a tough second quarter with revenue falling to $335 million, down 67% from the $1 billion the company had reported in the same period last year. Despite this, Airbnb saw an increase in domestic travel as people are interested in changing their surroundings during the pandemic. Airbnb still plans to IPO this year. Read More
Uber EATS revenue surpasses Uber ride-hailing in Q2 - Due to a sharp decline in Uber’s core ride-hailing business, Uber made more in revenue from their EATS business than they did from the ride-hailing service. Uber’s overall revenue fell 29% to $2.2 billion in the second quarter. Read More
Daily Interview Problem Solution
Two strings are anagrams of one another if they have the exact same character counts. In other words, “actt” and “tact” are anagrams since both strings have 1 a, 1 c and 2 t’s.
Therefore, all we care about (when making the anagram comparison) is the character counts! Therefore, we can just encode each string as a count of each character from
a-z. For example, “tact” would be
Then, we can create a hash table where the key is the character-count encoding and the values are the original strings (from the input array) that map to that encoding.
You can check the code out (and run it!) using this REPL.