new files
update algorithm from O(N) space to O(1)