You are viewing a single comment's thread. Return to all comments →
Perl:
sub existElement { my $element = shift; my $arr = shift; for (my $i = 0; $i <= scalar(@$arr) - 1; $i++){ if ($arr->[$i] eq $element) { return ($arr->[$i] eq $element) ? 1 : 0; last; } } } sub stringConstruction { my @s = split("", shift); my $res = [0]; my $cnt = 0; foreach my $el (@s) { if (!existElement($el, $res)) { push(@$res, $el); $cnt++; } } return $cnt; }
Seems like cookies are disabled on this browser, please enable them to open this website
String Construction
You are viewing a single comment's thread. Return to all comments →
Perl: