796. Rotate String

796. Rotate String

class Solution {
 public boolean rotateString(String A, String B) {
	     return rotateString( A,  B , 0);
	    }

	private boolean rotateString(String a, String b, int i) {
        if( a.length() <=1 && b.length()  b.length()) return false;
		if( a.equals(b)) return true;

 			return rotateString( a.substring(1)+a.charAt(0), b, i+1);
		}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s