摘要:
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,... 阅读全文
摘要:
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 阅读全文