☕ BIG win for developers
Apple reduces the app store fees to 15% for small developers. We talk about Binary Search. New SQL interview question.
Hi Everyone!
Hope you’re all having a fantastic day!
Tech Dive
No tech dive for today unfortunately! Here’s the schedule for future tech dives
Tomorrow - Serverless Applications
Stay tuned!
Interview Question
You have a relational database with an Employee Table.
The Employee Table has a column with Employee Ids (primary key) and a column with Employee Salaries.
Write an SQL query to get the nth highest salary from the Employee table.
We’ll send the solution tomorrow!
Industry News
Apple reduces App Store cut to 15% for developers who earn less than $1 million dollars in revenue
Apple’s App Store commission (the % cut Apple takes from any in-app purchases) has long been criticized as too high by many developers (and companies).
Apple takes 30% of all revenue as their App Store fee. This is obviously a significant chunk of revenue and has resulted in multiple lawsuits against Apple (most recently by Epic Games).
In response, the company has now amended their policy with the new App Store Small Business Program. This allows any developer who earns less than $1 million dollar in annual sales from all their apps to qualify for a reduced App Store cut of 15%, so half of the previous fee of 30%.
Additionally, this is a pretty brilliant PR move by Apple. Apple was getting sued by Epic Games and part of Epic’s lawsuit stated that Apple’s fees hurt small developers. Now, Apple has changed their policy to nullify that part of Epic’s lawsuit without significantly affecting their revenues from the App Store.
The App Store generated an estimated $50 billion in revenue in 2019. According to Sensor Tower, Apps that made less than $1 million dollars only accounted for 5% of the App Store’s total revenue.
So, this policy would result in an ~2.5% reduction in Apple’s App Store commissions, a pretty small sum in exchange for reduced regulatory scrutiny.
This policy will likely be copied by other App Stores, such as the Google Play Store.
Previous Solution
As a reminder, here’s the previous question
You are given an array as input. The elements in the array are all integers.
A peak element is an element that is greater than its neighbors.
Find a peak element in the array and return it’s index.
You can assume that the left and right borders of the array represent negative infinity.
Example
Input - [1,2,1,3,5,6,4]
Output - 1 or 5
Solution
The brute force way to solve this question is with a linear pass. Check each number to see if it’s greater than the number before AND after it. If it is, then return the index.
Can we do better?
We can!
We can use a modified Binary Search algorithm to solve this question in logarithmic time.
Like Binary Search, we start with a left and right pointer, pointing at the first and last elements in the array.
We average the left and right pointer to get the middle index and we check if its element is greater than the element after it.
If it is, then that means that either
this index is a peak
there is a peak to the left of this index
Therefore, we can set the right pointer to the middle index and continue the Binary Search.
Otherwise, we’ll set the left pointer to the middle index + 1 and continue the Binary Search.
When the Binary Search terminates (when the left pointer is greater than the right pointer), we can just return the left pointer.
If you’re having trouble understanding this solution, check out this video. It’s a terrific explanation from a highly ranked competitive programmer.
If you have any feedback or questions, feel free to reply to this email!
Best,
Arpan