Matrix Search-search in sorted array

why its giving 1 wrong answer:

@YashJ,
This question can be done in O(n) https://ide.codingblocks.com/s/172548. We compare only the last element of row with target and accordingly either move down or left.