标签:ati code bsp value The ike stat with array
Union Two Sorted List with Distinct Value
Array:
public static List<Integer> unionTwoSortedArray(int[] arr1, int[] arr2){ int len1 = arr1.length; int len2 = arr2.length; int i = 0; int j = 0; List<Integer> list = new ArrayList<>(); while(i<len1 && j<len2){ if(arr1[i] < arr2[j]){ list.add(arr1[i]); i++; } else if(arr1[i] > arr2[j]){ list.add(arr2[j]); j++; } else{ list.add(arr2[j]); i++; j++; } } while(i<len1){ list.add(arr1[i]); i++; } while(j<len2){ list.add(arr2[j]); j++; } return list; }
Microsoft - Union Two Sorted List with Distinct Value
标签:ati code bsp value The ike stat with array
原文地址:https://www.cnblogs.com/incrediblechangshuo/p/8970166.html