making functions inline can get the TLE code accepted
This is my solution with inline function.
This is without inline keyword.(TLE)
making the function inline shortened execution time drastically.