C语言 | Leetcode C语言题解之第242题有效的字母异位词

题目:

题解:

bool isAnagram(char* s, char* t) {
    int len_s = strlen(s), len_t = strlen(t);
    if (len_s != len_t) {
        return false;
    }
    int table[26];
    memset(table, 0, sizeof(table));
    for (int i = 0; i < len_s; ++i) {
        table[s[i] - 'a']++;
    }
    for (int i = 0; i < len_t; ++i) {
        table[t[i] - 'a']--;
        if (table[t[i] - 'a'] < 0) {
            return false;
        }
    }
    return true;
}

相关推荐

  1. 【力扣】每日一242有效字母

    2024-07-22 20:24:01       18 阅读
  2. 力扣-242. 有效字母

    2024-07-22 20:24:01       62 阅读
  3. leetcode242. 有效字母

    2024-07-22 20:24:01       53 阅读
  4. 【Leetcode】242.有效字母

    2024-07-22 20:24:01       51 阅读
  5. Leetcode242.有效字母

    2024-07-22 20:24:01       55 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-22 20:24:01       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-22 20:24:01       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-22 20:24:01       45 阅读
  4. Python语言-面向对象

    2024-07-22 20:24:01       55 阅读

热门阅读

  1. 特别篇 函数基础

    2024-07-22 20:24:01       14 阅读
  2. 小抄 20240717

    2024-07-22 20:24:01       18 阅读
  3. [2024-7-22]面试题2

    2024-07-22 20:24:01       14 阅读
  4. PTA 基础题

    2024-07-22 20:24:01       14 阅读
  5. CUE-云原生配置语言

    2024-07-22 20:24:01       17 阅读
  6. QEMU入门

    2024-07-22 20:24:01       16 阅读
  7. Redis哨兵模式实践

    2024-07-22 20:24:01       15 阅读