0
Can anybody explain how this code is working?
I have made a code for this problem. https://www.sololearn.com/learn/4710/?ref=app But I still don't have any idea how it is working correctly. My code: https://code.sololearn.com/cWYA0oQHHgNA/?ref=app
2 Respostas
+ 2
The idea: If you have the N numbers of people, the first person will kill the second and give the sword to the third and third person will kill the fourth and the sword will be given to the fifth and so on to the last person and thus the N-1 person will kill the last person and the sword remains with him
0
In that code k is increasing double rate compare to j, so after n/2 iterations h[0] has already reached n th value. I am not understanding how it is taking values after that.