摘要: 1.经典的N皇后问题就是个经典的DFS算法我摆到第一行第一列了哦,然后就开始Deep看下一行,可以放哪,然后递推,直到棋盘的行列到。 void NQueenHelper(vector> & board, vector>& result, int row) { int N = board.size(); if (row == N)//reached end scenario { string str; vector final; for (int i = 0; i>& board,... 阅读全文
posted @ 2014-02-16 14:26 来自海边的一片云 阅读(615) 评论(0) 推荐(0) 编辑
摘要: Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens="catsanddog",dict=["cat", "cats", "and", "sand", "dog"].A 阅读全文
posted @ 2014-02-16 13:55 来自海边的一片云 阅读(400) 评论(0) 推荐(0) 编辑