Maximum length Biotonic Subarray

is this the good approach i am using

Hello @Learning_bunny,

Yes, it is an optimal approach to solve this problem.