+ 9
⛷ Challenge ⛷ Find the largest string from the given string...
Suppose user Enters a string "Goodcommunication" You have to count no of letters in string from starts and whenever a repeated character ouucers from previous string cut the previous string and start counting new string from current letter this explanation will little bit confuse you I will show you example check out 1st comment for example... if you need more explanation mentioned in cmnts https://code.sololearn.com/cn4zPRALAtF1/?ref=app
10 Respostas
+ 8
Thanks for the challenge.
Here's my answer :
https://code.sololearn.com/cb6C4xnFiSZH/?ref=app
+ 4
ex->String=GoodCommunication
string 1=Go(2)
string 2=odC(3)
string 3=om(2)
string 4=municat(7)
string 5=ion(3)
largest string is string4.
+ 3
yes@rabee
+ 2
// this is my answer, correct me if i wrong
#include <bits/stdc++.h>
using namespace std;
char lower(char c)
{
if(c >= 'A' && c <= 'Z')
return c-'A'+'a';
return c;
}
int main() {
string s;
cin >> s;
bool memo[26];
memset(memo, false, sizeof memo);
int longest= -1, indeks =1, count=1,i=1, answer;
memo[(int)lower(s[0])-'a']=true;
while(i < (int)s.size())
{
char c = lower(s[i]);
if(memo[(int)c-'a']) //visited
{
if(count > longest ){
longest = count;
answer = indeks;
}
indeks++;
count = 0;
memset(memo,false,sizeof memo);
}
else
{
memo[(int)c-'a'] = true;
count++;
i++;
}
}
if(count > longest ){
longest = count;
answer = indeks;
}
cout<<answer<<endl;
return 0;
}
+ 2
@ramabena
your code executing without an error..
but showing wrong output...
my largest String size is 7 but your program shows output as 4...
check it out correct it
+ 2
this is the correct answer,
https://code.sololearn.com/cBUNNIjnR61h/?ref=app
+ 1
yes it's working brother nice approch
+ 1
Here is my solution.
https://code.sololearn.com/cOziFIVWuy5V/#py
Also enabled it to print all strings that have an equal length to the largest string length.
+ 1
in other words u want the program to return the longest sequence of charachters without any repetition, right?
0
python functional oneliner
https://code.sololearn.com/c1Iu7XEvKLaM/?ref=app