Let $A$ and $B$ be two finite sets such that there are exactly $144$ sets which are subsets of $A$ or subsets of $B$. Find the number of elements in $A \cup B$.
1. Let \( A \) and \( B \) be two finite sets. We are given that there are exactly 144 sets which are subsets of \( A \) or subsets of \( B \). This can be expressed as:
   \[
   2^{|A|} + 2^{|B|} - 2^{|A \cap B|} = 144
   \]
   Here, \( 2^{|A|} \) represents the number of subsets of \( A \), \( 2^{|B|} \) represents the number of subsets of \( B \), and \( 2^{|A \cap B|} \) represents the number of subsets of \( A \cap B \) which are counted twice in the sum \( 2^{|A|} + 2^{|B|} \).

2. We need to find the values of \( |A| \), \( |B| \), and \( |A \cap B| \) such that the equation holds. Let's denote \( |A| = a \), \( |B| = b \), and \( |A \cap B| = c \). Then the equation becomes:
   \[
   2^a + 2^b - 2^c = 144
   \]

3. The closest power of 2 less than 144 is \( 2^7 = 128 \). Let's assume \( a = 7 \). Then:
   \[
   2^7 + 2^b - 2^c = 144
   \]
   Simplifying, we get:
   \[
   128 + 2^b - 2^c = 144
   \]
   \[
   2^b - 2^c = 16
   \]

4. The difference between \( 2^b \) and \( 2^c \) is 16. We need to find \( b \) and \( c \) such that this holds. Notice that:
   \[
   2^5 = 32 \quad \text{and} \quad 2^4 = 16
   \]
   Therefore, \( b = 5 \) and \( c = 4 \).

5. Now, we have \( a = 7 \), \( b = 5 \), and \( c = 4 \). We need to find the number of elements in \( A \cup B \). Using the principle of inclusion-exclusion:
   \[
   |A \cup B| = |A| + |B| - |A \cap B|
   \]
   Substituting the values, we get:
   \[
   |A \cup B| = 7 + 5 - 4 = 8
   \]

The final answer is \(\boxed{8}\).