7.2. - another algorithm with O(1) additional space (but more complexity)