add solution

add an O(1) time solution