fork download
  1. #include <stdio.h>
  2. #include <limits.h>
  3.  
  4. int check_match(const char* A, const char* B) {
  5. int table[1 << CHAR_BIT] = {0};
  6. while (*A != '\0') {
  7. table[(size_t)*A] += 1;
  8. A++;
  9. }
  10.  
  11. while (*B != '\0') {
  12. table[(size_t)*B] -= 1;
  13. if (table[(size_t)*B] < 0) {
  14. return 0;
  15. }
  16. B++;
  17. }
  18. return 1;
  19. }
  20.  
  21. int main() {
  22. printf("%s\n",check_match("Hello world","ollw l")?"TRUE":"FALSE");
  23. printf("%s\n",check_match("Hello world","ww l")?"TRUE":"FALSE");
  24. }
  25.  
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
TRUE
FALSE