We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
func counterGame(n int64) string {
// Write your code here
for count := 0; n > 1; count++{
if n & (n-1) > 0 {
var power int64 = 1
for power <= n {
power = power << 1
}
n -= power >> 1
} else{
n /= 2
}
if (count%2 == 0) && (n == 1) {
return "Louise"
} else if (count%2 == 1) && (n == 1){
return "Richard"
}
}
return "Richard"
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Counter game
You are viewing a single comment's thread. Return to all comments →
func counterGame(n int64) string { // Write your code here
}