Answer to Question #278800 in C for ttttttt

Question #278800

The students of Dr. Kyle have submitted an unique string that Dr. Kyle gave them for homework. He is checking the strings of student A and student B which are denoted as  and . Dr. Kyle wants to find out if they copied each other's work. If the string  can be transformed into string  with rotations, it'll be obvious to Dr. Kyle that they have cheated.


1
Expert's answer
2021-12-13T10:23:07-0500
#include <stdio.h>
#include <stdbool.h>

char count[256];

int main() {
  char *a, *b;
  scanf("%s %s", &a, &b);
  for (int i = 0; i < strlen(a); i++)
    count[a[i]]++;
  for (int i = 0; i < strlen(b); i++)
    count[b[i]]++;
  bool flag = true;
  for (int i = 0; i < 256; i++)
    if (count[i] != 0) flag = false;
  if (flag)
    printf("unique");
  else
    printf("not unique"); 
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS