Better HN
topnewbestaskshowjobs
Log inSign up

leongrande

3 karma · joined Apr 24, 2018 (8y ago) · 1 submissions

Submissions

comment 8y ago · link · parent

You need not to sort the strings. Create a vector with indices he ascii codes, incrementing for the first string and decrementing the count for the second, and keep a count of the number of chars, if you get a negative number exit false, else if the count of chars is zero then each one is an anagram of the other. (n+m+128) operations n and m are the length of both strings and 128 for creating the vector