diff --git a/AndroidApplication.7z b/AndroidApplication.7z new file mode 100644 index 0000000..d42093c Binary files /dev/null and b/AndroidApplication.7z differ diff --git a/Challenge 1 b/Challenge 1 new file mode 100644 index 0000000..d0eaf26 --- /dev/null +++ b/Challenge 1 @@ -0,0 +1,30 @@ +class Main { + public static void main(String[] args) { + int array[] = {9, 1, 5, 9, 0}; + System.out.println(firstDuplicateIn(array)); + } + + + public static int firstDuplicateIn(int[] array) { + int result = 0; + for (int index = 0; index < array.length; index++){ + int x = array[index]; + + for (int index2 = index+1; index2 < array.length ; index2++){ + int number = array[index2]; + if (x == number){ + result = x; + return x; + + + } + else{ + System.out.println(x + " not equal " + number); + } + + + } + } + return result; + } +} diff --git a/Challenge 1 Question 2 b/Challenge 1 Question 2 new file mode 100644 index 0000000..77d3205 --- /dev/null +++ b/Challenge 1 Question 2 @@ -0,0 +1,33 @@ +class Main { + public static void main(String[] args) { + String testString = "kljfdsa"; + boolean result = isPalindrome(testString); + System.out.println(testString + " is " + result); + + + testString = "Hannah"; + result = isPalindrome(testString); + System.out.println(testString + " is " + result); + + + } +static boolean isPalindrome(String testString) { + int position = 0; + int matchingPosition = testString.length() - 1; + if (testString.charAt(position) == testString.charAt(matchingPosition)){ + while (position < matchingPosition){ + if (testString.charAt(position) == testString.charAt(matchingPosition)){ + position += 1; + matchingPosition -= 1; + return true; + } + else { + return false; + } + } + + + } + return false; + } + }