correct ans but exceeding time limit