Solution #1: Brute force

Let’s start by looking at the brute force solution to this problem:

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.