Optimize algorithm using extra data sturcture of usedRows and
usedDiagonals