1. For two strings A and B, if A and b appear in the same type of characters and each character appears the same number of times, then A and B are deformed words, design an efficient algorithm to check whether two given strings are mutually deformable words.
Given the two strings a and B and their lengths, return a bool value that indicates whether they are mutually deformed words.
Test examples:
"ABC", 3, "BCA", 3
Return: True
/* Use the array to simulate the hash table, each character corresponding to the ASCII code as an array subscript every time the corresponding character appears to initialize the array to 0 to assign a value of 1, so that the other string only need to find in this array, if each character corresponding to the array element is 1, then Illustrates that two strings are deformed words, not */class Transform {public: bool Chktransform (string A, int lena, string B, int lenb) { //write C Ode here if (LENA!=LENB)//length is not equal to direct return false return False ; const char *PA=A.C_STR ();//convert string to const char* const char *pb=b.c_str (); int arr[256]={0}; while (*PA) { arr[*pa]=1; pa++; } while (*PB) { if (arr[*pb]!=1) return false; pb++; } return true; }};
Several problems in string processing