String1 is rotating match for

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了String1 is rotating match for相关的知识,希望对你有一定的参考价值。

 

String Rotation. Given two string check if String1 is rotating match for String2

 

# Given two strings. Write a function that will return true if one string is a rotation of the other string.
# e.g. ‘bca‘ and ‘cab‘ are rotations of ‘abc‘ and the function should return true
# ‘barbazfoo‘, ‘oobarbazf‘ and ‘rbazfooba‘ are rotations of ‘foobarbaz‘

def is_rotation(string1, string2):
import java.util.Scanner;

public class StringCheck {
	
	public static void main(String[] args) {

		Scanner scan=new Scanner(System.in);
		String s1=scan.next();
		String s2=scan.next();
		String s=s2+s2;
		if (s1.length() == s2.length()){
			return s.contains(s1);
		} else {
			return false;
		}
}

}

  

以上是关于String1 is rotating match for的主要内容,如果未能解决你的问题,请参考以下文章

Opencv c++Template/Pattern Matching Scale and Rotation invariant

字符串

Java基础_正则表达

Leetcode 1752. Check if Array Is Sorted and Rotated

[GeeksForGeeks] Find if there is a pair with a given sum in a sorted and rotated array.

SpringThe matching wildcard is strict……