+ 2

Detect repetition in strings

I have a list of strings: abckdgsos hdksabcjso uddsgsabc oshdoabcj etc. In each set of strings there are only a certain substring that is repeated. In this case it is "abc". I tried making a for loop that would go through every character of every string, but it takes too long to complete the task. It is basically a nested loop inside a nested loop. Any suggestions or help will be greatly appreciated.

11th Jun 2017, 3:52 PM
Limitless
Limitless - avatar
7 Antworten
+ 6
yeah as u can see that i have replaced a string of single character with that of "" (null value)..... you can replace the similar string (here "abc") with that of null ("")........
11th Jun 2017, 4:59 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 5
see my code which removes similar characters from two strings https://code.sololearn.com/cR2pDR3jNNau/?ref=app its in java.....
11th Jun 2017, 4:14 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 4
line 22 and 23
11th Jun 2017, 5:04 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 4
use this String a = "abckdgsos"; a=a.replace("abc","");
11th Jun 2017, 5:06 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 1
Hmm It's a good concept, but do you think we can do something similar with strings instead of characters? @chirag ghosh
11th Jun 2017, 4:30 PM
Limitless
Limitless - avatar
+ 1
At which line are you referring to?
11th Jun 2017, 5:04 PM
Limitless
Limitless - avatar
+ 1
Hmm. My problem is that the code should detect the repetition in strings, without any string coded in the program. I'll go play a bit with your code and see if I can figure something out.
11th Jun 2017, 5:08 PM
Limitless
Limitless - avatar