diff --git a/FindtheOne/FindTheOne.class b/FindtheOne/FindTheOne.class new file mode 100644 index 0000000..e0d85d9 Binary files /dev/null and b/FindtheOne/FindTheOne.class differ diff --git a/FindtheOne/FindTheOne.java b/FindtheOne/FindTheOne.java new file mode 100644 index 0000000..39b4d4b --- /dev/null +++ b/FindtheOne/FindTheOne.java @@ -0,0 +1,28 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * FindTheOne + * given an array of ints, find the one that start with 1 + */ +public class FindTheOne { + public static void main(String[] args) { + + int[] arr = { 1, 23, 123, 45, 67, 176 }; + System.out.println(OneOne(arr)); + } + + private static List OneOne(int[] arr) { + List Ones = new ArrayList<>(); + String[] Convereted = new String[arr.length]; + for (int i = 0; i < arr.length; i++) { + Convereted[i] = String.valueOf(arr[i]); + } + for (String str : Convereted) { + if (str.startsWith("1")) { + Ones.add(str); + } + } + return Ones; + } +}