-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIsograms.cpp
More file actions
38 lines (33 loc) · 872 Bytes
/
Isograms.cpp
File metadata and controls
38 lines (33 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<iostream>
#include<algorithm>
#include<vector>
#include <array>
#include<cmath>
#include <string>
#include <unordered_set>
#include <cctype>
using namespace std;
bool is_isogram(string str)
{
unordered_set<char> seen;
for (char ch : str) {
char lower_ch = tolower(ch);
if (seen.find(lower_ch) != seen.end()) {
return false;
}
seen.insert(lower_ch);
}
return true;
}
int main()
{
cout << is_isogram("isIsogram");
return 0;
}
/*Description:
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.
Example: (Input --> Output)
"Dermatoglyphics" --> true
"aba" --> false
"moOse" --> false (ignore letter case)
*/