dcsimg
 

Submitted by: Octavia Anghel(octaviaanghel@gmail.com)

Friday May 8th 2020 by Octavia Anghel

Language: Java, Expertise: Intermediate - Learn how to write a single line of code that will tell you whether or not str2 is a rotation of str1.

Given two strings, str1 and str2, the code below shows a single line of code that returns whether or not str2 is a rotation of str1.

return (str1 + str1).matches("(?i).*" + Pattern.quote(str2) + ".*");
Home
Mobile Site | Full Site