I couldnt get the two wall method working in linear time