Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

merge without extra space

public void merge(int a1[], int a2[], int n1, int n2) {
        // code here
        int i = 0, j = 0, k = n1 - 1;
    while (i <= k && j < n2) {
        if (a1[i] < a2[j])
            i++;
        else {
            int temp = a2[j];
            a2[j] = a1[k];
            a1[k] = temp;
            j++;
            k--;
        }
    }
    Arrays.sort(a1);
    Arrays.sort(a2);
	
    }
Comment

PREVIOUS NEXT
Code Example
Java :: 2048 java code 
Java :: java variable 
Java :: java continue statement 
Java :: convert integer arraylist to array java 
Java :: Java Define a Functional Interface in java 
Java :: java assert 
Java :: java break string at comma 
Java :: how to find a word in a statement java 
Java :: java add two arrays together 
Java :: java int 0/0 
Java :: how to skip a line with a filewriter java 
Java :: multithreading in java 
Java :: remove duplicates from list java 
Java :: random value between 10-20 
Java :: java final modifier on method 
Java :: how to use Add Grepper Answer (a) 
Java :: terminate function calling in java 
Java :: switch statement in java 
Java :: format specifier in java 
Java :: add string to array java 
Java :: POST method) in spring rest api 
Java :: method overloading 
Java :: creating a properties object using a file 
Java :: fabricmc concat text 
Java :: create fragment constructor in arrayadapter 
Java :: https://graph.instagram.com/14.0/10218560180051171 
Java :: bukkit how to make a cancelable event 
Java :: access db in fragments 
Java :: power of a number in java 
Java :: Calculator repeat 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =