Now find the O(1) algorithm