This is the half implementation of staircase search but why m i not able to get the key element?
hello @thakur0_0

we can not perform these updation .
as we will always have two valid option to choose.
Approach that u can follow->
You can follow the following steps:
- Let the given element be x, create two variable i = 0, j = n-1 as index of row and column
- Run a loop until i < n && j>=0
- Check if the current element is greater than x then decrease the count of j. Exclude the current column.
- Check if the current element is less than x then increase the count of i. Exclude the current row.
- If the element is equal then print the position and en
@aman212yadav but dont you think this should search in all the row one by one and if the element is found then its should print out , why that is not working , i m not quite understanding ?
ok got ur point , so basically u are applying binary search in each row .
yeah that should definetely work.
i didnt notice that for loop outside bs my bad.
check statement where u r computing mid.
add bracket .
mid=(sc+ec)/2
this is my implementation for staircase ,can i optimise my code more like in a single loop both can be done or is it correct way. @aman212yadav
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.
