Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8433139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:18:19+00:00 2026-06-10T06:18:19+00:00

I have two strings a and b . I want to know if a

  • 0

I have two strings a and b. I want to know if a is rotation of b or vice versa without creating a third string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:18:20+00:00Added an answer on June 10, 2026 at 6:18 am

    A string a is a rotation of b if and only if there is an L such that L == len(a) == len(b), and there is an offset 0 <= j < len(a) such that a[ (i+j) % L] == b[i] for all 0 <= i < L.

    In c code (assuming that L is the common length of the strings. Returns 1 if a is a rotation of b, 0 otherwise):

    int i, j, is_rot;
    for (i = 0; i< L; i++){
        is_rot = 1;
        for (j = 0; j<L; j++){
            if (a[ (j + i) %L] != b[j] ){
                is_rot = 0;
                break;
            }
        }
        if (is_rot) return 1;
    }
    return 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two strings in a php i want to make following checks in
I have two strings in a java program, which I want to mix in
I have two MySQL tables, and I want to find and replace text strings
I have two different arrays, one with strings and another with ints. I want
I have two possible widths for a string i want to display in a
I have two Perl string variables containing date values. I want to check whether
I want to test whether two languages have a string in common. Both of
I have two strings String s1=426F62; String s2=457665; The strings are in hex representation.
I have two cell arrays of strings, and I want to check if they
Currently I have two larger vectors of 50+ strings I want to be able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.