O(1) space solution added