STRV Interview Question

How would you implement this functionality?