# ☕ Apple's new strategy

### Apple looks into a new service. Time Series databases are blowing up! They were the fastest growing type of database in the enterprise space. Plus a solution to our last coding interview problem.

Hi Everyone!

Hope you’re all having a great day!

Here’s your Interview Problem, Yesterday’s Solution and Tech Snippets for the day!

# Tech Dive

Our last tech dives were on Distributed Systems and Database Sharding!

# Tech Snippets

The Rise of the Time Series Database

One of the most notable trends in databases is the Time Series database. Last year, TSDB was the fastest growing type of database in the enterprise space.

Time series data is a sequence of data points collected over time (denoted by timestamps). Time series databases (TSDB) are optimized for storing and serving time series data very quickly.

TSDB can offer quick answers to statistical questions about data for a range of time periods. They also make maintenance chores (like clearing out old data) extremely easy to automate

Time series data is becoming more critical for enterprises with things like log files, IoT data, event tracking, etc. Many of these data files can be indexed by time.

Popular Time Series Databases include…

InfluxDB

Prometheus

Druid

Timescale DB

Apple plans to launch a Podcast subscription service

Apple has been shifting their business strategy focus on subscription products with Apple Music, Apple TV+ and Apple Fitness+.

Apple is now looking at the Podcasting market as an area for a new subscription product.

Apple is considering allowing podcasters to charge for episode access on the Podcasts app. This could entice creators to commit exclusively to Apple Podcasts.

Apple Podcasts is currently the dominant podcast player with Spotify being a #2.

Spotify shares tumbled 7% after the news came out as Apple’s increased focus on podcasting could be a threat to Spotify

# Interview Question

Given an array `nums`

of *n* integers and an integer `target`

, find three integers in `nums`

such that the sum is **closest** to `target`

.

Return the sum of the three integers.

You may assume that each input would have exactly one solution.

Here’s the question in LeetCode.

*We’ll send a detailed solution tomorrow, so make sure you move our emails to primary, so you don’t miss them!*

**Gmail users**—move us to your primary inbox

**On your phone?**Hit the 3 dots at the top right corner, click "Move to" then "Primary"**On desktop?**Back out of this email then drag and drop this email into the "Primary" tab near the top left of your screen

**Apple mail users**—tap on our email address at the top of this email (next to "From:" on mobile) and click “Add to VIPs”

# Previous Solution

**As a refresher, here’s the previous question**

You are given a binary tree containing digits from 0 - 9 only.

Each root to leaf path represents a number. A root to leaf path of 1 -> 3 -> 4 represents the number 134.

Find the total sum of *all* root to leaf numbers.

Here’s the question in LeetCode.

**Solution**

We can solve this question with a tree traversal in a Depth First fashion.

We’ll keep track of the current path by using an integer.

Everytime we want to add a digit to the integer, we multiply it by 10 and then take the sum with the new digit.

Everytime we want to remove the last digit, we divide the number by 10 and truncate it.

We’ll keep track of the sum of all the paths with a variable called `totalSum`

.

We use a recursive function to do our Depth First traversal.

In our recursive function, we first add the digit at the current node to a variable that keeps track of the path (`curVal`

). We multiply `curVal`

by 10 and then add the sum with the new digit at the current node.

If the current node is a leaf, then we add `curVal`

to `totalSum`

Otherwise, we recurse on the node’s children.

After, we remove the digit we added to `curVal`

(similar to how you’d do in backtracking) by dividing `curVal`

by 10 and truncating.

After the traversal, we can return `totalSum`

.

Here’s the solution in Python 3

Best,

Arpan

## Create your profile

## Only paid subscribers can comment on this post

Log in## Check your email

For your security, we need to re-authenticate you.

Click the link we sent to , or click here to log in.