Two solution for searching 2D matrix