• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
frankM
天下武功,唯快不破。
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

随笔分类 -  DFS

 
LeetCode Letter Combinations of a Phone Number
摘要:链接:https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/递归算法:class Solution{ public: vector letterCombinations(str... 阅读全文
posted @ 2015-02-06 01:37 frankM 阅读(98) 评论(0) 推荐(0)
LeetCode Sum Root to Leaf Numbers
摘要:链接: https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/dfs..sum保存中间结果.每计算完一条路径,就更新ans/** * Definition for binary tree * struct TreeNode { * ... 阅读全文
posted @ 2014-12-02 19:37 frankM 阅读(165) 评论(0) 推荐(0)
LeetCode Path Sum
摘要:链接: https://oj.leetcode.com/problems/path-sum/深度优先搜索,.求出个从根到叶子节点的和..注意树中有负树/** * Definition for binary tree * struct TreeNode { * int val; * T... 阅读全文
posted @ 2014-11-24 22:25 frankM 阅读(158) 评论(0) 推荐(0)
LeetCode Convert Sorted Array to Binary Search Tree
摘要:链接: https://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/把一个有序数组转换成一棵AVL树/** * Definition for binary tree * struct TreeNode { *... 阅读全文
posted @ 2014-11-04 21:35 frankM 阅读(148) 评论(0) 推荐(0)
HDU 1829 A Bug's Life
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1829用二分图做的,,,,,,刚学图,,以为这道题有向图跟无向图都没影响,,,贡献了N次WA。。调试了好久才找到原因,,贡献一组测试数据:89 1142 243 523 5412 5576 333 8989 ... 阅读全文
posted @ 2014-07-18 16:30 frankM 阅读(109) 评论(0) 推荐(0)
HDU 1016 Prime Ring Problem
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1016DFS的经典题#include#includeusing namespace std;int ring[25];bool prime[45];bool visit[25];void isprime(in... 阅读全文
posted @ 2014-06-27 22:38 frankM 阅读(125) 评论(0) 推荐(0)
POJ 2386 Lake Counting
摘要:链接:http://poj.org/problem?id=2386DFS 的入门级题目....依次递归8个方向即可:#include //#includeusing namespace std;char data[105][105];int n,m;void dfs(int x,int y){ ... 阅读全文
posted @ 2014-05-28 13:23 frankM 阅读(92) 评论(0) 推荐(0)
第七届河南省ACM A题
摘要:#include #includeusing namespace std;int data[105];int n,m;int ans;void dfs(int i,int sum){ if(sum==m) { ans++; return ; } i... 阅读全文
posted @ 2014-05-27 21:49 frankM 阅读(150) 评论(0) 推荐(0)
 

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3