Ad
public class DeadLock {
  static class ThreadOne implements Runnable {
    public void run()
    {
      synchronized (Integer.class)
      {
        System.out.println(Thread.currentThread().getName() + " - Got lock on Integer.class");
        synchronized (String.class)
        {
          System.out.println(Thread.currentThread().getName() + " - Got lock on String.class");
        }
      }
    }
  }

  static class ThreadTwo implements Runnable {

    public void run()
    {
      synchronized (String.class)
      {
        System.out.println(Thread.currentThread().getName() + " - Got lock on String.class");
        synchronized (Integer.class)
        {
          System.out.println(Thread.currentThread().getName() + " - Got lock on Integer.class");
        }
      }
    }
  }
}

We have natural sequesnce of numbers with a missed 1 element. How can we find the missing element

public class MissingInt {
  public static int findMissingElement(int[] array) {
  // write yor code here
    int XOR = 0;
    for (int i = 0; i < array.length; i++) {
      if (array[i] != 0) {
        XOR ^= array[i];
      }
      XOR ^= (i + 1);
      
    }
    XOR ^= array.length + 1;
    return XOR;
  }
}