Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- struct out{
- int f;
- int s ;
- int len;
- };
- out CenterDiscustion(int first,int second, string sub){
- int res = 0 , f1 = first , s1 = second;
- while(f1 >= 0 && sub[f1] == sub[s1]){
- res = s1 - f1 + 1;
- f1--;
- s1++;
- }
- out l {
- f1 + 1, s1 - 1 , res};
- return l ;
- }
- string StringReturner(string s){
- out len1 , len2 , res{0 , 0 , 0};
- if ( s.length() < 1) return "";
- int f = 0 , se = 0;
- for(int i = 0; i < s.size(); i++){
- len1 = CenterDiscustion(i , i , s);
- len2 = CenterDiscustion(i, i + 1, s);
- if (res.len < len1.len){
- res = len1;
- }
- if (res.len < len2.len){
- res = len2;
- }
- }
- string re = s.substr(res.f , res.len);
- return re;
- }
- int main() {
- string a = "blll";
- string k = StringReturner(a);
- cout << k;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement