`

简单算法

阅读更多

简单算法如下, 核心思路是值域有限,转化成反函数

bool isUsedByA[256] = {0};
bool isUsedByB[256] = {0};

for each value in a[]
begin
    isUsedByA[static_cast<unsigned char>(value)] = true;
end

for each char_elem in b[]
begin
    isUsedByB[static_cast<unsigned char>(value)] = true;
end

define buffer c
step idx from 0 to 255
begin
    if (isUsedByA[idx] && !isUsedByB[idx])
    {
        c.push_back(idx);
    }
end

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics