Suppose a fair coin is tossed repeatedly until the same outcome occurs twice in a row


backend options

intern statement

I would love to join a team of people building a product that I’m passionate about. The internship will provide invaluable production experience while still being a student. I get to work with an amazing group of Network Service developers, and learn ideas and concepts that can be used in future projects.


public static int merge(int[] a, int p, int q, int r)
    //p=0, q=1, r=3
    int countingInversion = 0;
    int n1 = q-p+1;
    int n2 = r-q;
    int[] temp1 = new int[n1+1];
    int[] temp2 = new int[n2+1];
    for(int i=0; i<n1; i++) temp1[i] = a[p+i];
    for(int i=0; i<n2; i++) temp2[i] = a[q+1+i];

    temp1[n1] = Integer.MAX_VALUE;
    temp2[n2] = Integer.MAX_VALUE;
    int i = 0, j = 0;

    for(int k=p; k<=r; k++)
        if(temp1[i] <= temp2[j])
            a[k] = temp1[i];
            a[k] = temp2[j];
    return countingInversion;
public static void main(String[] args)
    int[] a = {1, 20, 6, 4, 5};
    int countInversion = mergeSort(a, 0, a.length-1);