N queens question in leetcode