Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case.
- #include <stdbool.h>
- #include <stdint.h>
- #include <string.h>
- bool IsIsogram(const char *str)
- {
- uint32_t bits;
- size_t idx;
- for(bits = idx = 0; idx < strlen(str); ++idx)
- if(idx == __builtin_popcountl(bits |= 1L << (str[idx] & 0x1f)))
- return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement