2016年校招真题
nn
SYaoJun
这个作者很懒,什么都没留下…
展开
-
顺时针打印矩阵
题目 类型:数组 模拟 注意:cnt来统计,而且在四个操作中也要加,不然会出错。 class Printer { public: vector<int> clockwisePrint(vector<vector<int> > matrix, int m, int n) { if(!m) return {}; if(m==1...原创 2020-03-29 13:00:23 · 101 阅读 · 0 评论 -
最后一个字符
题目 类型:字符串 注意:使用fgets比较快 #include <bits/stdc++.h> using namespace std; const int N = 1e6+5; int dp[256]; int main(){ char str[N]; int k; scanf("%d", &k); getchar(); while(...原创 2020-03-29 11:38:06 · 127 阅读 · 0 评论 -
回文串
题目 公司:蘑菇街 类型:字符串 模拟 题意:添加一个字符是否可以构成回文串。 类似题:leetcode 680. 验证回文字符串 Ⅱ #include <bits/stdc++.h> using namespace std; int main(){ string str; while(cin>>str){ int n = str.size(); //既然增加一...原创 2020-03-27 23:08:29 · 105 阅读 · 0 评论 -
直方图内最大矩形
题目 公司:美团 类型:单调栈 题意:找到一个数组中形成的最大矩形。leetcode84题原题。 class MaxInnerRec { public: int countArea(vector<int> A, int n) { //单调栈 stack<int> stk; stk.push(-1); i...原创 2020-03-27 22:28:20 · 102 阅读 · 0 评论 -
最长公共子序列
题目 类型:动态规划 题意:找到最长公共子序列的长度,不要求连续。 class LCS { public: int findLCS(string A, int n, string B, int m) { vector<vector<int>> dp(n+1, vector<int>(m+1)); int res = 0; ...原创 2020-03-27 15:34:05 · 221 阅读 · 0 评论 -
最长公共子串
题目 类型:动态规划 题意:求连续的最长公共子串 class LongestSubstring { public: int findLongest(string A, int n, string B, int m) { int res = 0; vector<vector<int>> dp(n+1, vector<int>...原创 2020-03-27 15:30:22 · 108 阅读 · 0 评论 -
上台阶
题目 公司:京东 类型:动态规划 斐波那契数列 题意:注意开始位置是台阶1 class GoUpstairs { public: int f[103]; const int M = 1e9+7; int countWays(int n) { memset(f, 0, sizeof f); f[1] = 0; f[2] = 1;...原创 2020-03-27 14:58:16 · 214 阅读 · 0 评论