diff --git a/medium/day_8/solution.cpp b/medium/day_8/solution.cpp index 4f32122..669069f 100644 --- a/medium/day_8/solution.cpp +++ b/medium/day_8/solution.cpp @@ -1 +1,53 @@ -//Write your code here \ No newline at end of file +//Write your code here +#include +using namespace std; +string getsequence(string str, int idx1, int idx2) // this function returns the repeating sequence of string starting with str[i] +{ + + string temp = ""; // temp shows the repeating sequence + while (idx2 < str.length()) + { + if (str[idx1] == str[idx2]) + { + temp += str[idx1]; + idx1++; + idx2++; + } + else + break; + } + return temp; +} +int main() +{ + string str; + string AnsStr; + cin >> str; // input the string + if(str.length() == 1) + { + cout<<-1< MaxLength) //if length of current repeating sequence is greater than previously stored length + { // then update max length + AnsStr=temp;//store max repeating sequence in AnsStr + MaxLength=len; + } + } + i++; + } + + cout<