Design‎ > ‎Design Pattern‎ > ‎


- XOR All array elements to get A ^ B, if elements repeat even time except A,B which are odd times repeat.

- See which bit in A ^ B is (1), say bit b.
  XOR All elements which has bit b as (1) & get A.
  Else XOR All elements which has bit b as (0) & get B.

- If elements of array are 1 to N, see 1st element and mark the element at its index as -ive.
   [3, 2, 1, 1, 2]
   [3, 2, -1 ,1, 2]
   If the element is already -ive, it is a repeat. This destroys the Array, need to recover.

- With m sorted arrays, find smallest element (jth array) by using m size min-heap and again put next element from jth array to get next smallest element.