+ 1
What is wrong with this code?
The below code is not giving the expected output ***Program to check 2 strings are rotationally equal or not*** https://code.sololearn.com/cA25A5A12A14 Please fix the logic/ code Logic I have used: -- Take 2 string inputs. Take one of them, say str1 -- swap adjacent characters in a string once to shift the first character to the last. i.e., rotating a string to the left. eg. hello --> elloh is left rotated by one character -- rotating such string by 1time, 2 times, 3 times, ---, n-1 times will give all rotational equivalents and checking each string against the second string str2. If any of anyone matches, the strings are rotationally equivalent, otherwise no.
1 Respuesta
+ 2
Strings should be compared with equals.
Line 42: if(string1.equals(string2))
https://www.sololearn.com/discuss/153817/?ref=app