I didn't get the code

question- https://www.geeksforgeeks.org/print-maximum-shortest-distance/

i don’t get the hashmap approach in his code kindly explain me with your code if you can

@anubhavb11 sabse pehle sabka values ka shortest distance nikal rahe hai left side and right side se aur uska min b[a[i]] pe store kar rahe hai. phir iterate karke agar k-a[i] map mein present hai (ex a[i] =3 , k=5, so agar 2 present hai) tab undono ke shortest dist ka max lete hai (dono b[x] and b[k-x] mein stored hai ) and final ans ka minimum. basically map use karke agar x hai toh direct k-x ko dhund sakte hai o(1) mein isliye effecient hai.
(ek baar dry run karke bhi dekhlo aajayega samajh)
hope its cleared if yes dont forget to hit like and mark resolved :smiley:

yrr unka likha hua code nahi samajh aa rha ek baar aap apni language mai code kr do please

@anubhavb11

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.