Code not working for kth element from last

build function had problem added comments where update made