Refactored p167 base case
Solved 375 base case