☕ Big Tech reveals financials

Hey Guys,

Hope you’re having an awesome day!

We’re going to be trying something new out today. We’re running a weekly raffle for a Mock Coding Interview / Mentoring Session with a Senior Software Engineer at Google!

Details on how to enter the raffle are in the Interview Problem section below….

Interview Problem

You are given the root to a binary search tree.

Find the second largest node in the tree and return it.

Reply back to this email with how you’d solve this question. We’ll give you anywhere from 1 to 3 points depending on the quality of your answer.

You will always get at least 1 point for replying. So you should definitely give it a shot!

Every point you get is an entry into our weekly raffle!

This week’s raffle is a Mock Coding Interview / Mentoring Session with a Senior Software Engineer at Google!

As always, we’ll send you a complete solution with test cases tomorrow!

Industry News

Big Tech companies released earnings reports….

Apple

  • Earnings for the quarter slightly exceeded Wall Street expectations.

    • Revenue: $64.7 billion - up 1% year-over-year

    • iPhone revenue: $26.44 billion - down 20.7% year-over-year

    • Services revenue: $14.55 billion - up 16.3% year-over-year

    • Other Products revenue: $7.88 billion - up 20.9% year-over-year

    • Mac revenue: $9.0 billion - up 28% year-over-year

    • iPad revenue: $6.8 billion - up 46% year-over-year

    • Gross margin: 38.2%

Facebook

  • Earnings for the quarter greatly exceeded Wall Street expectations.

    • Earnings: $2.71 cents per share, vs $1.91 per share forecast by Refinitiv

    • Revenue: $21.47 billion, vs $19.8 billion forecast by Refinitiv

    • Daily active users (DAUs): 1.82 billion vs. 1.79 billion forecast by FactSet

    • Monthly active users (MAUs): 2.74 billion vs.2.7 billion forecast by FactSet

    • Average revenue per user (ARPU): $7.89 vs. $7.32 forecast by FactSet

  • In the US and Canada, Facebook’s user base fell to 196 million daily active users from 198 million a quarter earlier. That’s mainly because the user base had been elevated during the second quarter due to the impact of COVID-19.

Amazon

  • Earnings for the quarter greatly exceeded Wall Street Expectations

    • Earnings: $12.37 vs $7.41 per share expected, according to analysts surveyed by Refinitiv

    • Revenue: $96.15 billion vs $92.7 billion expected, according to analysts surveyed by Refinitiv

    • Sales: $112 - $121 billion dollars, up 28 - 38% year over year

    • AWS Revenue: $11.6 billion dollars, up 29% year over year

Google

  • Earnings for the quarter greatly exceeded Wall Street expectations.

    • Profit: $11.2 billion dollars

    • Digital Advertising Revenue: $37.1 billion dollars

    • YouTube Revenue: $5 billion dollars, up 32% year over year

    • Google Cloud Revenue: $3 billion dollars, up 44% year over year

Previous Solution

As a refresher, here’s the previous question

You are given a list of words as input.

Find all pairs of unique indices such that the concatenation of the two words is a palindrome.

Input - ["bat","dcba","lls","s","sssll", "cat", "tab"]

Output - [[0,6],[3,2],[2,4],[6,0]]

Solution

The brute force solution would be to check every possible word pair and see if they form a palindrome. There are O(n^2) word pairs and checking if a word is a palindrome takes O(w) time. Therefore, the time complexity would be O(n^2 * w)

Instead, we can create a hash table with all the words and then check all the prefixes and postfixes of every word. If the reverse of a word’s prefix is in the dictionary and it is palindromic, then we can add the indices of the two words to our dictionary. The same goes for a word’s postfix and the reverse of it’s postfix. The only difference is in that scenario, we have to reverse the order of the indices when we add them to our results.

This changes our time complexity to O(n * w^2). This will likely be a good tradeoff since the number of words will far outweigh the length of the words in most inputs.

Don’t forget to reply to this email with your solution for today’s interview problem if you want to be included in the raffle!

Best,

Arpan