Answers for "string rotation codevita solution python"

0

string rotation codevita solution python

C#include <stdio.h>
#include <string.h>
int final_answer(char string[], char resultant_string[],int n,int q){
    int i,j,k,f,ans,r,anagram_array[26];
    char temp[10];
    
    for(i=0;i<n;i++){
        r=0;
        for(j=i;j<n;j++){
            for(f=0;f<26;f++){
                anagram_array[f]=0;
            }
            temp[r]=string[j];
            temp[r+1]='\0';
            r++;
            if(strlen(temp)>q)
                break;
            else if(strlen(temp)==q){
                ans=0;
                for(k=0;k<q;k++){
                    anagram_array[resultant_string[k]-97]+=1;
                    anagram_array[temp[k]-97]-=1;
                }
                for(k=0;k<26;k++){
                    if(anagram_array[k]!=0)
                        ans=1;
                }
                if(ans==0)
                    return 1;
            }
        }
    }
    return 0;
}
int main()
{
    int count=0,i,j,q,n,times;
    char string[30],direction,resultant_string[10];
    scanf("%s",string);
    scanf("%d",&q);
    n=strlen(string);
    for(i=0;i<q;i++){
        scanf("\n%c %d",&direction,×);
        if(direction=='L')
            count=count+times;
        else
            count=count-times;
        count=count%n;
        resultant_string[i]=string[count];
    }
    resultant_string[q]='\0';
    printf("%s",resultant_string);
    if(final_answer(string,resultant_string,n,q))
        printf("yes");
    else
        printf("no");
    return 0;
}
Posted by: Guest on October-26-2021

Code answers related to "string rotation codevita solution python"

Python Answers by Framework

Browse Popular Code Answers by Language