Please describe in detail one efficient way to solve this problem and what makes this method efficient. Also, describe in detail one inefficient way to solve this problem and what makes this method inefficient.