瀏覽代碼

Finished Lab

CWinarski 6 年之前
父節點
當前提交
eecbbbbe7f
共有 1 個文件被更改,包括 10 次插入3 次删除
  1. 10
    3
      src/main/java/com/zipcodewilmington/arrayutility/ArrayUtility.java

+ 10
- 3
src/main/java/com/zipcodewilmington/arrayutility/ArrayUtility.java 查看文件

@@ -15,9 +15,16 @@ public class ArrayUtility<T> {
15 15
     }
16 16
 
17 17
     public T getMostCommonFromMerge(T[] arrayToMerge) {
18
-        Arrays.sort(mergeArrays(arrayToMerge));
19
-        for( )
20
-        return null;
18
+        mergeArrays(arrayToMerge);
19
+        Integer indexCount = 0;
20
+        T currentMatch = null;
21
+        for( T elementInArray : mergedArray){
22
+            if (getNumberOfOccurrences(elementInArray) > getNumberOfOccurrences(mergedArray[indexCount +1])){
23
+                currentMatch = elementInArray;
24
+                indexCount++;
25
+            }
26
+        }
27
+        return currentMatch;
21 28
     }
22 29
 
23 30
     public Integer countDuplicatesInMerge(T[] arrayToMerge, T valueToEvaluate) {