What is the time complexity and space complexity of my c++ code?


  • 1
    E
    void merge(int A[], int m, int B[], int n) {
         int len = m + n -1;  
        for (int i = m - 1, j = n - 1; j >= 0 ; )  
        {  
            if (i>=0 && A[i] > B[j]) A[len--] = A[i--];  
            else A[len--] = B[j--];  
        }  
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.