+ 1
To check if a Substring is present in a Circular String in java.Can anyone help me to solve?
Eg.Breeze(consider as circular string) Substring to check 1.eez(ans->true) 2.rez(false) 3.ebr(true)
5 Réponses
+ 1
The simplest way would probably be to concatenate the word with itself and then search for the substring.
+ 1
Is there's no other way like without using String Functions.?
+ 1
Thanks for the help
0
String class has method contains() that can be used to check character sequence in a string..
Ex:
"Breeze".contains("eez") ; //returns true
edit:
for circularly, yes. add word+word then apply substring....
0
I don't understand without using string functions means? Do you want find your own way.. Or any other functions?
for formar way:
You can use a loop
and search linearly for substring is in main string like
Breeze is ebr => I=0 to string length, search for char e,then with another inner loop find next 3 letters, if match stop else continue outer loop.
start from e ,position find e, next is out of length , repeat from start index.
Or for any other function, string has "string".indexof("substring") ; returns index of substring if match, else return -1. For circular passion, use string+string. Else you can find other way by using of loop easily...
You can also use regex search advancely..
Hope it helps...