This is important question as per Interview point, I tried my best to explain it.
Any better solution Always welcome.