diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Main.java b/src/Main.java index 930198c..9984d6f 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,3 +1,5 @@ +import java.util.ArrayList; + //TIP To Run code, press or // click the icon in the gutter. public class Main { @@ -11,5 +13,21 @@ public static void main(String[] args) { // for you, but you can always add more by pressing . System.out.println("i = " + i); } + // quick test + System.out.println("is the word 'water' unique? " + isUnique("water")); + System.out.println("is the word 'never' unique? " + isUnique("never")); + } + + public static boolean isUnique(String word) { + ArrayList letters = new ArrayList<>(); + for (char letter : word.toCharArray()) { + if(letters.contains(letter)){ + return false; + } + else { + letters.add(letter); + } + } + return true; } } \ No newline at end of file