c++算法
60506013
这个作者很懒,什么都没留下…
展开
-
地牢逃脱
#include <iostream> #include <map> #include <vector> #include <algorithm> #include <queue>using namespace std;int main() { int R,C; while(cin>>R>>C){ queue<pair<int,int> > bfs;原创 2017-03-20 21:06:11 · 412 阅读 · 0 评论 -
leetcode:0-1 矩阵问题
//DFS (Time Limited) class Solution { public: int dfs(vector<vector<int>> &matrix,int i,int j,int R,int C,bool** visited){ int res=R+C; if (0==matrix[i][j]) return 0; visited[原创 2017-03-20 17:11:20 · 1890 阅读 · 1 评论 -
leetcode-wildcard match
递归(Time Limited),便于理解class Solution { public: bool isMatch(string s, string p) { if (p.empty()) return s.empty();//同空为真 if (p[0]!='*'){ if (s[0]==p[0]||(p[0]=='?'&&!s.em原创 2017-03-15 15:29:30 · 601 阅读 · 0 评论 -
leetcode-Regular expression match
class Solution { public: bool isMatch(string s, string p) { int lens=s.size(),lenp=p.size(),i,j; if (p.empty()) return s.empty();//wise!!!! if (p[1]!='*'){ //第一种原创 2017-03-15 15:22:47 · 222 阅读 · 0 评论 -
leetcode-wordBreak
动态规划 dp[i]=true为i之前的子串能被分割为字典当中的词class Solution { public: bool wordBreak(string s, vector<string>& wordDict) {//dynamic programming unordered_map<string,int> dict; if (wordDict.siz原创 2017-03-15 14:56:51 · 316 阅读 · 0 评论 -
c++ 引用
这里写代码片 #include <iostream> using std::namespace void func(int &p) { p=2; } int main() { int a; func(a); cout<<"a="<<a<<endl; }原创 2016-03-17 15:54:55 · 193 阅读 · 0 评论 -
c语言算法笔试(1)-------链表逆序
单向链表逆序O(n)复杂度原创 2015-10-21 14:11:55 · 538 阅读 · 0 评论