Fast Way to Find Difference between Two Strings of Equal Length in Perl

前端 未结 4 1220
无人及你
无人及你 2021-01-03 01:20

Given pairs of string like this.

    my $s1 = \"ACTGGA\";
    my $s2 = \"AGTG-A\";

   # Note the string can be longer than this.

I would

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-03 01:45

    Use binary bit ops on the complete strings.

    Things like $s1 & $s2 or $s1 ^ $s2 run incredibly fast, and work with strings of arbitrary length.

提交回复
热议问题