|
|
@@ -77,18 +77,29 @@ public class StringArrayUtils {
|
|
77
|
77
|
*/ // TODO
|
|
78
|
78
|
public static boolean isPalindromic(String[] array) {
|
|
79
|
79
|
|
|
80
|
|
- return Arrays.equals(reverse(array), array);
|
|
|
80
|
+ return Arrays.equals(array, reverse(array));
|
|
81
|
81
|
}
|
|
82
|
82
|
|
|
83
|
83
|
/**
|
|
84
|
84
|
* @param array array of String objects
|
|
85
|
85
|
* @return true if each letter in the alphabet has been used in the array
|
|
86
|
|
- */ // TODO
|
|
|
86
|
+ */ //TODO
|
|
87
|
87
|
public static boolean isPangramic(String[] array) {
|
|
88
|
|
- boolean[] letterPresent = boolean[26];
|
|
89
|
|
- if (){
|
|
|
88
|
+ String concatString = "";
|
|
|
89
|
+ String alphabet = "qwertyuiopasdfghjklzxcvbnm";
|
|
|
90
|
+ boolean panagramic = true;
|
|
|
91
|
+ for (int i=0; i<array.length; i++){
|
|
|
92
|
+ concatString += array[i];
|
|
|
93
|
+ }
|
|
|
94
|
+ char[] alphArr = alphabet.toCharArray();
|
|
|
95
|
+ for (int i=0; i<alphabet.length(); i++){
|
|
90
|
96
|
|
|
|
97
|
+ if (concatString.indexOf(alphArr[i])<0){
|
|
|
98
|
+ panagramic = false;
|
|
|
99
|
+ break;
|
|
|
100
|
+ }
|
|
91
|
101
|
}
|
|
|
102
|
+ return panagramic;
|
|
92
|
103
|
}
|
|
93
|
104
|
|
|
94
|
105
|
/**
|
|
|
@@ -97,7 +108,14 @@ public class StringArrayUtils {
|
|
97
|
108
|
* @return number of occurrences the specified `value` has occurred
|
|
98
|
109
|
*/ // TODO
|
|
99
|
110
|
public static int getNumberOfOccurrences(String[] array, String value) {
|
|
100
|
|
- return 0;
|
|
|
111
|
+ int counter=0;
|
|
|
112
|
+ for (int i=0; i<array.length; i++) {
|
|
|
113
|
+ if (array[i].equals(value)){
|
|
|
114
|
+ counter++;
|
|
|
115
|
+ }
|
|
|
116
|
+ }
|
|
|
117
|
+ return counter;
|
|
|
118
|
+
|
|
101
|
119
|
}
|
|
102
|
120
|
|
|
103
|
121
|
/**
|
|
|
@@ -106,7 +124,16 @@ public class StringArrayUtils {
|
|
106
|
124
|
* @return array with identical contents excluding values of `value`
|
|
107
|
125
|
*/ // TODO
|
|
108
|
126
|
public static String[] removeValue(String[] array, String valueToRemove) {
|
|
109
|
|
- return null;
|
|
|
127
|
+ int valueCount = getNumberOfOccurrences(array, valueToRemove);
|
|
|
128
|
+ String[] arrayMinusValue = new String[array.length-valueCount];
|
|
|
129
|
+ int counter = 0;
|
|
|
130
|
+ for(int i=0; i<array.length; i++){
|
|
|
131
|
+ if (!array[i].equals(valueToRemove)){
|
|
|
132
|
+ array[i]=arrayMinusValue[counter];
|
|
|
133
|
+ counter++;
|
|
|
134
|
+ }
|
|
|
135
|
+ }
|
|
|
136
|
+ return arrayMinusValue;
|
|
110
|
137
|
}
|
|
111
|
138
|
|
|
112
|
139
|
/**
|