|
@@ -53,7 +53,9 @@ public class StringArrayUtils {
|
53
|
53
|
public static boolean contains(String[] array, String value) {
|
54
|
54
|
|
55
|
55
|
for (String v : array) {
|
|
56
|
+
|
56
|
57
|
if (value == v) {
|
|
58
|
+
|
57
|
59
|
return true;
|
58
|
60
|
}
|
59
|
61
|
}
|
|
@@ -71,9 +73,11 @@ public class StringArrayUtils {
|
71
|
73
|
for (int i = 0; i < array.length / 2; i++) {
|
72
|
74
|
|
73
|
75
|
temp = array[i];
|
|
76
|
+
|
74
|
77
|
array[i] = array[array.length - i - 1];
|
75
|
78
|
array[array.length - i - 1] = temp;
|
76
|
79
|
}
|
|
80
|
+
|
77
|
81
|
return array;
|
78
|
82
|
}
|
79
|
83
|
|
|
@@ -85,10 +89,10 @@ public class StringArrayUtils {
|
85
|
89
|
public static boolean isPalindromic(String[] array) {
|
86
|
90
|
|
87
|
91
|
for (int i = 0; i < array.length; i++) {
|
|
92
|
+
|
88
|
93
|
if (!array[i].equals(array[array.length - 1 - i])) {
|
89
|
94
|
|
90
|
95
|
return false;
|
91
|
|
-
|
92
|
96
|
}
|
93
|
97
|
}
|
94
|
98
|
return true;
|
|
@@ -103,22 +107,27 @@ public class StringArrayUtils {
|
103
|
107
|
String combo = "";
|
104
|
108
|
|
105
|
109
|
for (int i = 0; i < array.length; i++){
|
|
110
|
+
|
106
|
111
|
String temp = array[i].toLowerCase();
|
107
|
112
|
String[] tempArray = temp.split(" ");
|
|
113
|
+
|
108
|
114
|
for (int j = 0; j < tempArray.length; j++){
|
109
|
115
|
combo += tempArray[j];
|
110
|
116
|
}
|
111
|
117
|
}
|
112
|
118
|
String[] apart = combo.split("");
|
113
|
|
-
|
114
|
119
|
String[] counter = new String[26];
|
|
120
|
+
|
115
|
121
|
for (int i=0; i<apart.length; i++) { //z-z=0 ; z-a=25 (26-26=0 ; 26-1=25)
|
116
|
122
|
if (counter['z' - apart[i].charAt(0)] == null) {
|
|
123
|
+
|
117
|
124
|
counter['z' - apart[i].charAt(0)] = apart[i];
|
118
|
125
|
}
|
119
|
126
|
}
|
120
|
127
|
for (int i=0; i<26; i++){
|
|
128
|
+
|
121
|
129
|
if (counter[i]==null){
|
|
130
|
+
|
122
|
131
|
return false;
|
123
|
132
|
}
|
124
|
133
|
}
|
|
@@ -136,7 +145,9 @@ public class StringArrayUtils {
|
136
|
145
|
int count = 0;
|
137
|
146
|
|
138
|
147
|
for (int i = 0; i < array.length; i++) {
|
|
148
|
+
|
139
|
149
|
if (array[i] == value) {
|
|
150
|
+
|
140
|
151
|
count++;
|
141
|
152
|
}
|
142
|
153
|
}
|
|
@@ -155,12 +166,13 @@ public class StringArrayUtils {
|
155
|
166
|
List<String> arrList = new ArrayList<String>();
|
156
|
167
|
|
157
|
168
|
for (int i = 0; i < array.length; i++) {
|
|
169
|
+
|
158
|
170
|
if (array[i] != valueToRemove) {
|
159
|
171
|
|
160
|
172
|
arrList.add(array[i]);
|
161
|
|
-
|
162
|
173
|
}
|
163
|
174
|
}
|
|
175
|
+
|
164
|
176
|
String[] stringArr = new String[arrList.size()];
|
165
|
177
|
stringArr = arrList.toArray(stringArr);
|
166
|
178
|
|
|
@@ -183,9 +195,11 @@ public class StringArrayUtils {
|
183
|
195
|
String nextWord = array[i];
|
184
|
196
|
|
185
|
197
|
if(nextWord.equals(last)) {
|
|
198
|
+
|
186
|
199
|
newArr.set(newArr.size()-1, newArr.get(newArr.size()-1));
|
187
|
200
|
|
188
|
201
|
} else {
|
|
202
|
+
|
189
|
203
|
newArr.add(nextWord);
|
190
|
204
|
last = nextWord;
|
191
|
205
|
}
|
|
@@ -210,15 +224,15 @@ public class StringArrayUtils {
|
210
|
224
|
String nextWord = array[i];
|
211
|
225
|
|
212
|
226
|
if(nextWord.equals(last)) {
|
|
227
|
+
|
213
|
228
|
newArr.set(newArr.size()-1, newArr.get(newArr.size()-1)+nextWord);
|
214
|
229
|
|
215
|
230
|
} else {
|
|
231
|
+
|
216
|
232
|
newArr.add(nextWord);
|
217
|
233
|
last = nextWord;
|
218
|
234
|
}
|
219
|
235
|
}
|
220
|
236
|
return newArr.toArray(new String[newArr.size()-1]);
|
221
|
237
|
}
|
222
|
|
-
|
223
|
|
-
|
224
|
238
|
}
|