These were the coding questions which I was asked can anyone tell me the approach to both the problem?