Last active
March 27, 2020 12:02
-
-
Save olumidayy/b0a812210b94c363e65938c9e2d8d021 to your computer and use it in GitHub Desktop.
day3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
print(isIsogram2('qw- - e rty')); | |
print(isIsogram('qw- - e rty')); | |
} | |
String letters = 'abcdefghijklmnopqrstuvwxyz'; | |
bool isIsogram(String word){ | |
String newStr = ''; | |
for(int i = 0; i < word.length; i++){ | |
var letter = word[i]; | |
if(newStr.contains(letter) && letters.contains(letter)){ | |
return false; | |
}else{ | |
newStr += letter; | |
} | |
} | |
return true; | |
} | |
bool isIsogram2(word){ | |
for(int i = 0; i < word.length; i++){ | |
var letter = word[i]; | |
if(word.indexOf(letter) != word.lastIndexOf(letter) && letters.contains(letter)){ | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment