This is my solution for Fibonacci String : Solution
First I sort the given string, then push the occurance of all uniqe characters in a vector. Then I search for the triplet where
v(i) = v(j) + v(k)
But when I submit the solution I keep getting WA. Can someone please help me find my mistake.
“If any such permutation of the elements of C satisfies f(c_i)=f(c_i−1)+f(c_i−2) for all i≥3, the string is said to be a dynamic string.”
It says for all i , not for any i
while (j < k) {
if (arr[i] == arr[j] + arr[k]) {
cout << "Dynamic" << endl;
Looks like you’re checking for any i.
Ok thank you…so what should do to check for all ’ i ’ ?