Search a 2D Matrix II
I thinks it's o(max(m, n))
I divide the matrix into four parts and discard two parts in every recursion. Here is my post with explanation. My solution only beats 21%.
this is so smart! much better than my binary search solution.
@jaewoo In the second solution (O(mlogn)), why did you have to divide the matrix along the rows? Why not just simply loop through the row indices as below?
@jianchao.li.fighter very precise and clear solution. thanks for sharing!
I love your code. always easy to understand and very concise. Thank you.
Awesome! It's like binary search version but to narrow search range step by step. Combining this, one may use binary search when target > [the node in a view of BST] to accelerate search.
so the time complexity should be m + n, right?
@StefanPochmann Thank you sharing your brilliant code.
No one has replied
Rather bad. What is N?
@StefanPochmann said in Python O(m+n) with clear search strategy:
No it isn't.
No it isn't.
Also, maybe this demonstrates it even better:
@greenflag Hi could you please explain why your solution is O(nlogm + mlogn)? I got a similar solution and had a hard time analyzing its run time.
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.