摘要: 请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则该路径不能再进入该格子。 分析:回溯算法 这是一个可以用回朔法解决的典型题。首先,在矩阵中任选 阅读全文
posted @ 2021-11-18 20:30 Zupernova 阅读(109) 评论(0) 推荐(0)
摘要: //模拟乘法进位操作 string add(string x, string y) { reverse(x.begin(), x.end()); reverse(y.begin(), y.end()); string ans; if (x.empty() && y.empty())return an 阅读全文
posted @ 2021-11-18 20:28 Zupernova 阅读(55) 评论(0) 推荐(0)
摘要: #include <iostream> #include <vector> #include <stack> #include <set> #include <string> #include <algorithm> using namespace std; int main(void) { int 阅读全文
posted @ 2021-11-18 20:27 Zupernova 阅读(14) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; int find(int a[],int len); void main() { int a[]={1,2,3,5,7,8,16}; int len=sizeof(a)/sizeof(int); cout<<find( 阅读全文
posted @ 2021-11-18 20:26 Zupernova 阅读(34) 评论(0) 推荐(0)
摘要: class Solution { public: ListNode* reverseList(ListNode* head) { if(!head)return NULL; ListNode* pre=new ListNode(-1); ListNode* tmp; while(head){ tmp 阅读全文
posted @ 2021-11-18 20:25 Zupernova 阅读(45) 评论(0) 推荐(0)
摘要: 经典解法一维 #include <iostream> using namespace std; bool sign = false; int num[9][9]; void Output() { for (int i = 0; i < 9; i++){ for (int j = 0; j < 8; 阅读全文
posted @ 2021-11-18 20:24 Zupernova 阅读(93) 评论(0) 推荐(0)
摘要: #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; bool cmp(const string& p1,const string& p2) { return 阅读全文
posted @ 2021-11-18 20:23 Zupernova 阅读(15) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; class Solution { public: string intToRoman(int num) { char* c[4][10]={ {"","I","II","III","IV","V","VI","VII", 阅读全文
posted @ 2021-11-18 20:23 Zupernova 阅读(55) 评论(0) 推荐(0)
摘要: bool fun(vector<int>& track, vector<int>& nums) { stack<int> t; int i = 0,j=0; for (int i = 0; i < nums.size();i++) { if (t.empty()||t.top() != track[ 阅读全文
posted @ 2021-11-18 20:22 Zupernova 阅读(71) 评论(0) 推荐(0)
摘要: #include <iostream> #include <vector> using namespace std; int main(void) { vector<int> m = { 5,6,7,8,9,10,11,12,14,15 }; vector<int> ans; int des = 2 阅读全文
posted @ 2021-11-18 20:21 Zupernova 阅读(17) 评论(0) 推荐(0)
摘要: #include <iostream> #include <string> #include <cmath> #include <vector> #include <map> #include <algorithm> using namespace std; int m, n; vector<vec 阅读全文
posted @ 2021-11-18 20:20 Zupernova 阅读(56) 评论(0) 推荐(0)
摘要: 问题:在N行N列的棋盘上,一位骑士按象棋中“马走日”的走法从初始坐标位置(SX, SY)出发,要求遍历(巡游)棋盘中每一个位置一次。请输出其实巡游的位置顺序,或输出无解。 #include <iostream> using namespace std; // 棋盘边长、起始位置、总步数 const 阅读全文
posted @ 2021-11-18 20:19 Zupernova 阅读(68) 评论(0) 推荐(0)
摘要: #include <iostream> #include <stdio.h> #include <string.h> #include <conio.h> using namespace std; typedef struct student { int data; struct student * 阅读全文
posted @ 2021-11-18 20:16 Zupernova 阅读(130) 评论(0) 推荐(0)
摘要: #include <iostream> #include <vector> #include <stack> #include <set> #include <string> #include <algorithm> using namespace std; int main(void) { str 阅读全文
posted @ 2021-11-18 20:12 Zupernova 阅读(29) 评论(0) 推荐(0)
摘要: //我的方法 #include <iostream> #include <vector> #include <stack> #include <set> #include <string> #include <algorithm> using namespace std; void fun(vect 阅读全文
posted @ 2021-11-18 20:11 Zupernova 阅读(48) 评论(0) 推荐(0)
摘要: //全排列数->部分排列数->///(部分)组合数:好像不对/// //myprint->取全排列前n个->部分排列数基础上加上单调验证 #include <iostream> #include <vector> #include <stack> #include <set> #include <s 阅读全文
posted @ 2021-11-18 20:09 Zupernova 阅读(53) 评论(0) 推荐(0)
摘要: #include <iostream>//一个更加形象的代码,不仅求出最大长度,同时用二维数组存储每个阶段的最长子序列 #include <vector> #include <stack> #include <algorithm> using namespace std; void newpush( 阅读全文
posted @ 2021-11-18 20:08 Zupernova 阅读(27) 评论(0) 推荐(0)
摘要: 第一题:求获胜者,如果票数相当,按照字典序排序 输入: Tom,Lily,Tom,Lucy,Lucy,Jack 输出: Lucy #include <iostream> #include <vector> #include <stack> #include <set> #include <strin 阅读全文
posted @ 2021-11-18 20:07 Zupernova 阅读(87) 评论(0) 推荐(0)
摘要: #include <iostream> #include <vector> #include <stack> #include <set> #include <string> #include <algorithm> using namespace std;//L为左括号数,R为右括号数,限制条件为 阅读全文
posted @ 2021-11-18 20:06 Zupernova 阅读(43) 评论(0) 推荐(0)
摘要: #include <iostream> #include <vector> using namespace std; vector<int> t; void traceback(int total, int n,int len) { if (n == 0||total == 0) { for (in 阅读全文
posted @ 2021-11-18 20:05 Zupernova 阅读(55) 评论(0) 推荐(0)