Skip to content

12-malak/rotatestr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

rotatestr

class Solution { public boolean rotateString(String s, String goal) {

int sLen = s.length();
int goalLen = goal.length();

if(sLen != goalLen) {
  return false;
}

s = s + s;
final char goalFirstChar = goal.charAt(0);

for(int i = 0; i < goalLen; ++i) {

  if(s.charAt(i) == goalFirstChar) {

    int j = 0;

    while(++j < goalLen && s.charAt(i + j) == goal.charAt(j));

    if(j == goalLen) {
      return true;
    }
  }
}

return false;

} }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published