implmented runtime of O(1) solution
implmented runtime of O(1) solution