Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static ArrayList<Integer> merge_one_into_another(ArrayList<Integer> arr1, ArrayList<Integer> arr2) {
- int i = 0;
- int j = 0;
- while(i < arr1.size()) {
- if(arr1.get(i) <= arr2.get(j) || arr2.get(j) == 0) {
- for(int i1 = arr2.size()-1; i1 > j; i1--) {
- arr2.set(i1, arr2.get(i1-1));
- }
- arr2.set(j, arr1.get(i));
- i++;
- j++;
- } else {
- j++;
- }
- }
- return arr2;
- }
Add Comment
Please, Sign In to add comment