|
|
@@ -82,23 +82,22 @@ public class StringArrayUtils {
|
|
82
|
82
|
* @return true if each letter in the alphabet has been used in the array
|
|
83
|
83
|
*/ // TODO
|
|
84
|
84
|
public static boolean isPangramic(String[] array) {
|
|
85
|
|
- char[] alphabet = new char[26];
|
|
|
85
|
+ ArrayList<Character> Chars = new ArrayList<Character>();
|
|
86
|
86
|
|
|
87
|
87
|
for(String str: array){
|
|
88
|
88
|
char[] chars = str.toCharArray();
|
|
89
|
89
|
|
|
|
90
|
+ for(char car : chars){
|
|
|
91
|
+ if(!Chars.contains(car)){
|
|
|
92
|
+ Chars.add(car);
|
|
|
93
|
+ }
|
|
|
94
|
+ }
|
|
90
|
95
|
|
|
91
|
96
|
}
|
|
92
|
|
- return false;
|
|
93
|
|
- }
|
|
94
|
|
-
|
|
95
|
|
- private void isLetter(){
|
|
96
|
97
|
|
|
|
98
|
+ return Chars.size() == 26 ? true : false;
|
|
97
|
99
|
}
|
|
98
|
100
|
|
|
99
|
|
- private void isInCharArray(char[] chars, char Char){
|
|
100
|
|
-
|
|
101
|
|
- }
|
|
102
|
101
|
|
|
103
|
102
|
|
|
104
|
103
|
/**
|
|
|
@@ -122,12 +121,13 @@ public class StringArrayUtils {
|
|
122
|
121
|
* @return array with identical contents excluding values of `value`
|
|
123
|
122
|
*/ // TODO
|
|
124
|
123
|
public static String[] removeValue(String[] array, String valueToRemove) {
|
|
125
|
|
- //ArrayList<String> strings = new ArrayList<String>(Arrays.asList(array));
|
|
126
|
|
-
|
|
127
|
|
- //for(int i = 0; i < string.size()
|
|
128
|
|
-
|
|
129
|
|
-
|
|
130
|
|
- return null;
|
|
|
124
|
+ ArrayList<String> strings = new ArrayList<String>();
|
|
|
125
|
+ for(String str : array){
|
|
|
126
|
+ if(!str.equals(valueToRemove)){
|
|
|
127
|
+ strings.add(str);
|
|
|
128
|
+ }
|
|
|
129
|
+ }
|
|
|
130
|
+ return strings.toArray(new String[strings.size()]);
|
|
131
|
131
|
}
|
|
132
|
132
|
|
|
133
|
133
|
/**
|
|
|
@@ -135,7 +135,15 @@ public class StringArrayUtils {
|
|
135
|
135
|
* @return array of Strings with consecutive duplicates removes
|
|
136
|
136
|
*/ // TODO
|
|
137
|
137
|
public static String[] removeConsecutiveDuplicates(String[] array) {
|
|
138
|
|
- return null;
|
|
|
138
|
+ ArrayList<String> strings = new ArrayList<String>();
|
|
|
139
|
+ String prevString = "";
|
|
|
140
|
+ for(String str: array){
|
|
|
141
|
+ if(!prevString.equals(str)){
|
|
|
142
|
+ strings.add(str);
|
|
|
143
|
+ }
|
|
|
144
|
+ prevString = str;
|
|
|
145
|
+ }
|
|
|
146
|
+ return strings.toArray(new String[strings.size()]);
|
|
139
|
147
|
}
|
|
140
|
148
|
|
|
141
|
149
|
/**
|
|
|
@@ -143,7 +151,22 @@ public class StringArrayUtils {
|
|
143
|
151
|
* @return array of Strings with each consecutive duplicate occurrence concatenated as a single string in an array of Strings
|
|
144
|
152
|
*/ // TODO
|
|
145
|
153
|
public static String[] packConsecutiveDuplicates(String[] array) {
|
|
146
|
|
- return null;
|
|
|
154
|
+ ArrayList<String> strings = new ArrayList<String>();
|
|
|
155
|
+
|
|
|
156
|
+ boolean isDuplicated;
|
|
|
157
|
+ for(String str1: array){
|
|
|
158
|
+ isDuplicated = false;
|
|
|
159
|
+ for(String str2: array){
|
|
|
160
|
+ if(str1 == str2){
|
|
|
161
|
+ isDuplicated = true;
|
|
|
162
|
+ }
|
|
|
163
|
+ }
|
|
|
164
|
+ if(!isDuplicated){
|
|
|
165
|
+ strings.add(str1);
|
|
|
166
|
+ }
|
|
|
167
|
+ }
|
|
|
168
|
+
|
|
|
169
|
+ return strings.toArray(new String[strings.size()]);
|
|
147
|
170
|
}
|
|
148
|
171
|
|
|
149
|
172
|
|