O(n)time,O(1)space