## lokendra2211.verma

BAN USER#include<bits/stdc++.h>

using namespace std;

set<string> dictionary_set;

int maxchain(string s,int i,int j)

{

if(i>j) return 0;

if(i==j&&dictionary_set.find(s)!=dictionary_set.end())

return s.size();

if(i==j) return 0;

int x=maxchain(s.substr(i+1,j),i+1,j);

int y=maxchain(s.substr(i,j-1),i,j-1);

int z=maxchain(s.substr(i+1,j-1),i+1,j-1);

x=x>y?x:y;

return x>z?x:y;

}

int main(){

string [] input={"a","b","ab","ac","abc"};

int max=0;

for(int i=0;i<input.size();i++)

dictionary_set.inset(input[i]);

for(int i=0;i<n;i++)

{

int x=maxchain(input[i],0,input[i].size()-1);

if(max<x)

max=x;

}

cout<<max<<endl;

return 0;

}

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

#include<iostream>

- lokendra2211.verma June 05, 2018using namespace std;

class Square_sum{

int n;

public:

Square_sum(int n=0){};

long long int Fun_for_square(int n)

{

return (n*(n+1)*(2*n+1)/6);

}

}

int main()

{

Square_sum s;

int n;

cin>>n;

cout<< s.Fun_for_square(n)<<endl;

return 0;

}