TikTok interview question

Using numpy to write some optimization for basic operations.