×

# Hackerrank Hack 101 Aug 2013 Contest .

 2 Hello everybody , Yesterday night i participated in hacker rank contest and i solved one problem , VROOK My approach was something like this . Find a diff[n] ; where diff[i] = abs(p1[i]-p2[i]); Count the Odd number in diff array . if(count%2) { player 2 will win. } else { player 1 will win. } I got Wrong answer , Please anybody who took participate in Last night Hackerrank contest please suggest me your approach . You can view my solution here Happy Coding!!! asked 25 Aug '13, 11:52 2.3k●18●30●69 accept rate: 1%

 5 The solution is to consider each of the columns as a pile in a nim game . The pile size will be abs(p1[i]- p2[i])-1 , And answer will be xor of these values. If it is non zero , player 2 wins , else player 1 wins. answered 26 Aug '13, 01:26 627●1●7●13 accept rate: 27% 2.3k●18●30●69 1 @javadecoder thanks a lot now i got it .. if you have any other questions links please share with us so we can practice on nim game problems. (26 Aug '13, 10:03)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×310
×12

question asked: 25 Aug '13, 11:52

question was seen: 3,956 times

last updated: 26 Aug '13, 10:03