Java: Shift characters and compare

 

Given two strings A and B, return whether or not A can be shifted some number of times to get B.

 

For example,

     if A is abcde and B is cdeab, return true.

     If A is abc and B is acb, return false.


The Problem is much similar to :Using String inbuilt methods

Hope you can trace and understand easily 😊




Note:

·         The above solution is not the ultimate or the only way to approach the problem.

·         Attaching screenshot because you need to practice than copying code and executing in IDE.

·         As I said there are ‘N’ number of ways to solve the issue, here I tried using inbuilt methods from String class and get the solution.

·         Comments and suggestions are always welcome. git link: https://github.com/failed-peanut/java



Comments

Popular posts from this blog

Java: Given a String find the distinct characters in it and count it

Java: Reverse a singly linked list