LeetCode Letter Combinations of a Phone Number
摘要:链接:https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/递归算法:class Solution{ public: vector letterCombinations(str...
阅读全文
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 { * ...
阅读全文
LeetCode Path Sum
摘要:链接: https://oj.leetcode.com/problems/path-sum/深度优先搜索,.求出个从根到叶子节点的和..注意树中有负树/** * Definition for binary tree * struct TreeNode { * int val; * T...
阅读全文
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 { *...
阅读全文
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 ...
阅读全文
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...
阅读全文
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){ ...
阅读全文
第七届河南省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...
阅读全文