随笔分类 -  搜索

DFS和BFS
摘要:BFS 完全平方数 题目链接:https://leetcode-cn.com/problems/perfect-squares/ class Solution { public: int numSquares(int n) { int max_sqrt = floor(sqrt(n)); queue 阅读全文
posted @ 2020-08-17 10:31 NaughtyCoder 阅读(122) 评论(0) 推荐(0)
摘要:46. 全排列 题目链接:https://leetcode-cn.com/problems/permutations/ class Solution { public: vector<bool> flag; vector<vector<int>> res; vector<vector<int>> p 阅读全文
posted @ 2020-08-16 16:47 NaughtyCoder 阅读(96) 评论(0) 推荐(0)
摘要:78. 子集 题目链接:https://leetcode-cn.com/problems/subsets/ class Solution { public: vector<vector<int>> res; vector<int> path; vector<vector<int>> subsets( 阅读全文
posted @ 2020-08-16 16:29 NaughtyCoder 阅读(77) 评论(0) 推荐(0)
摘要:39. 组合总数 题目链接:https://leetcode-cn.com/problems/combination-sum/ class Solution { public: vector<vector<int>> res; vector<int> path; vector<vector<int> 阅读全文
posted @ 2020-08-16 14:58 NaughtyCoder 阅读(82) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/ 搜索与回溯 class Solution { public: int get_single_sum(int x){ int s = 0; while(x 阅读全文
posted @ 2020-05-04 14:20 NaughtyCoder 阅读(79) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/ju-zhen-zhong-de-lu-jing-lcof/ dfs class Solution { public: bool exist(vector<vector<char>>& board, string word) 阅读全文
posted @ 2020-05-04 13:45 NaughtyCoder 阅读(76) 评论(0) 推荐(0)
摘要:题目链接:https://leetcode-cn.com/problems/zi-fu-chuan-de-pai-lie-lcof/ 回溯1 class Solution { public: vector<string> ans; string path; vector<string> permut 阅读全文
posted @ 2020-04-29 18:22 NaughtyCoder 阅读(93) 评论(0) 推荐(0)