Please help me with the code is this challenge

as i am unable to crack the logic behind it so could you please help me with the code ??

hello @Anku47

check this->

explanation by prateek bhaiya -> link