completed single number II with less memory