how subtracting ’ - 1 ’ is helping us ???
Please explain that part.
how subtracting ’ - 1 ’ is helping us ???
Please explain that part.
hello @parth_tyagi
we have changed the behaviour of lower bound using omparator.
it will now behave as upper bound.
so whenever u search for any key it will return element that is greater than key.
so everytime we need to subtract from from the obtained index to get element which is less than equal to k
’ -1 ’ kyu use kar rahe h vo samajh gaya. Lekinjab me 100 pass karunga toh mujhe 100 waale index ka address milega…tab to -1 karne ki jaroorat nahi h phir kyu kar rahe h. Ek or cheez comparater " return a<=b; " is line me ’ a ’ and ’ b ’ konse numbers h…i mean kin do ko compare kar rahe h ???
…
nahi 100 wale ka nahi milega ,100 se bade element ka index milega kyunki humara lower bound ab upper bound ki tarah kaam karega.
second argument hamara target/key hota hai aur first argument current index pe value
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.