Avito Code Challenge 2018有哪些长尾词技巧可以分享?
- 内容介绍
- 文章标签
- 相关推荐
本文共计2811个文字,预计阅读时间需要12分钟。
A. Antipalindrome+直接暴力判断即可。
A. Antipalindrome
直接暴力判断就行了。
#include <bits/stdc++.h> using namespace std; const int N = 100; char s[N]; bool check(int i, int j) { while (i <= j) { if (s[i] != s[j]) return 0; i++; j--; } return 1; } int main() { scanf("%s", s); int n = strlen(s); for (int tail = n - 1; tail >= 0; tail--) { if (!check(0, tail)) { printf("%d\n", tail + 1); return 0; } } puts("0"); return 0; } View Code
B. Businessmen Problems
排序或者map都行。
本文共计2811个文字,预计阅读时间需要12分钟。
A. Antipalindrome+直接暴力判断即可。
A. Antipalindrome
直接暴力判断就行了。
#include <bits/stdc++.h> using namespace std; const int N = 100; char s[N]; bool check(int i, int j) { while (i <= j) { if (s[i] != s[j]) return 0; i++; j--; } return 1; } int main() { scanf("%s", s); int n = strlen(s); for (int tail = n - 1; tail >= 0; tail--) { if (!check(0, tail)) { printf("%d\n", tail + 1); return 0; } } puts("0"); return 0; } View Code
B. Businessmen Problems
排序或者map都行。

