Candy  O(n)

time complexity is O(n), space complexity is O(n)