Kaynağa Gözat

one problem left

nmaidanos 8 yıl önce
ebeveyn
işleme
512e87f9dc
1 değiştirilmiş dosya ile 11 ekleme ve 17 silme
  1. 11
    17
      StringArrayUtils.java

+ 11
- 17
StringArrayUtils.java Dosyayı Görüntüle

82
      * @return true if each letter in the alphabet has been used in the array
82
      * @return true if each letter in the alphabet has been used in the array
83
      */ // TODO
83
      */ // TODO
84
     public static boolean isPangramic(String[] array) {
84
     public static boolean isPangramic(String[] array) {
85
-        ArrayList<Character> Chars = new ArrayList<Character>();
85
+        
86
+        ArrayList<Character> alpha = new ArrayList<Character>();
86
        
87
        
87
         for(String str: array){
88
         for(String str: array){
88
-            char[] chars = str.toCharArray();
89
+            char[] chars = str.toLowerCase().replace(" ", "").toCharArray();
89
             
90
             
90
             for(char car : chars){
91
             for(char car : chars){
91
-                if(!Chars.contains(car)){
92
-                    Chars.add(car);
92
+                if(!alpha.contains(car)){
93
+                    alpha.add(car);
93
                 }
94
                 }
94
             }
95
             }
95
-            
96
         }
96
         }
97
         
97
         
98
-        return Chars.size() == 26 ? true : false;
98
+        return alpha.size() == 26 ? true : false;
99
     }
99
     }
100
     
100
     
101
     
101
     
151
      * @return array of Strings with each consecutive duplicate occurrence concatenated as a single string in an array of Strings
151
      * @return array of Strings with each consecutive duplicate occurrence concatenated as a single string in an array of Strings
152
      */ // TODO
152
      */ // TODO
153
     public static String[] packConsecutiveDuplicates(String[] array) {
153
     public static String[] packConsecutiveDuplicates(String[] array) {
154
-        ArrayList<String> strings = new ArrayList<String>();
154
+        ArrayList<String> strings   = new ArrayList<String>();
155
         
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);
156
+        for(int i = 0; i < array.length; i++){
157
+            for(int j = i; j < array.length; j++){
158
+                
166
             }
159
             }
160
+        
167
         }
161
         }
168
         
162
         
169
         return strings.toArray(new String[strings.size()]);
163
         return strings.toArray(new String[strings.size()]);