TLE. used four for loops. Need help for an efficient way.
https://www.youtube.com/watch?v=siKFOI8PNKM Watch this video and then try.