gives wrong answer in some cases
Code modification
@roopenmangat your approach is correct just you have missed the case wheb k is 0 and k is out of range ,for that I have applied modulo with n logic in main ,Please see the updated code and submit again,here is link:https://ide.codingblocks.com/s/177604
Hope you get it.Please rate your experience and feel free to ask any doubt.Happy coding 