Got 8/15 TCs using brute force n^2. can someone suggest better approach than n^2. thank you in advance.