Tesla Interview Question

How to vectorize this areay