+ 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)

3rd Apr 2022, 10:59 AM
SOUNTHERYA M
5 Respuestas
+ 1
The simplest way would probably be to concatenate the word with itself and then search for the substring.
3rd Apr 2022, 12:31 PM
Simon Sauter
Simon Sauter - avatar
+ 1
Is there's no other way like without using String Functions.?
4th Apr 2022, 3:43 AM
SOUNTHERYA M
+ 1
Thanks for the help
4th Apr 2022, 5:20 PM
SOUNTHERYA M
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....
3rd Apr 2022, 12:13 PM
Jayakrishna 🇮🇳
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...
4th Apr 2022, 9:41 AM
Jayakrishna 🇮🇳