华为OJ字符串运用-密码截取
来源:互联网 发布:scala和java混合使用 编辑:程序博客网 时间:2024/06/05 02:18
输入一个字符串
返回有效密码串的最大长度
#include <iostream> #include <string> #include <vector>#include <algorithm>//#include "Customer.h"#define Max(a,b) (a)>(b)?(a):(b)using namespace std;int getCatcher(string str, int i){int count1 = 0, count2 = 0;int pre = i - 1;int post = i + 1;while (pre>=0 && post<str.length() && str[pre] == str[post] ){pre--;post++;}count1 = post - pre - 1;pre = i;post = i + 1;while (pre >= 0 && post<str.length() && str[pre] == str[post] ){pre--;post++;}count2 = post - pre - 1;return Max(count1, count2);}int main(){string str;cin >> str;int max = 0;for (int i = 1; i < str.length(); i++){max = Max(max, getCatcher(str, i));}cout << max;return 0;}
0 0
- 【华为oj】字符串运用-密码截取
- 华为OJ(字符串运用-密码截取)
- 华为oj 字符串运用-密码截取
- 字符串运用-密码截取(华为oj)
- 【华为OJ】【027-字符串运用-密码截取】
- 【华为OJ】【057-字符串运用-密码截取】
- 华为OJ:字符串运用-密码截取
- 华为OJ 字符串运用-密码截取
- 华为oj中级 字符串运用-密码截取
- 华为OJ字符串运用-密码截取
- 华为OJ基础题-字符串运用-密码截取
- 华为OJ中级题-字符串运用-密码截取
- 华为OJ——字符串运用-密码截取
- 华为OJ——字符串运用-密码截取
- [华为OJ--C++]057-字符串运用-密码截取
- 华为oj中级 【中级】字符串运用-密码截取
- 华为OJ——字符串运用-密码截取
- 华为测试 字符串运用-密码截取
- wireshark 实用过滤表达式(针对ip、协议、端口、长度和内容)
- 带头结点的链式表操作集
- MySQL怎么安装
- 浅析Java抽象类和接口的比较
- Win7 下以管理员身份运行批处理文件,切换JDK版本
- 华为OJ字符串运用-密码截取
- ARCGIS10.1 插值分析结果按指定多边形输出
- jquery控制表单提交
- java练习 三、判断语句 三目运算符
- 【LeetCode】5. Longest Palindromic Substring
- 开源项目导入eclipse的一般步骤
- C#实现Base64的编码解码
- Elasticsearch入门笔记
- LeetCode55 Jump Game