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.
Java supports bitCount (a.k.a. Population Count or "popcnt") since JDK 1.5 (released in 2004), so the following is the simplest and fastest Java solution in O(1).
Java Solution in O(1)
long N = Long.parseUnsignedLong(in.next());
boolean LouiseWins = (Long.bitCount(N-1)&1) != 0;
System.out.println(LouiseWins? "Louise" : "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 →
Java supports bitCount (a.k.a. Population Count or "popcnt") since JDK 1.5 (released in 2004), so the following is the simplest and fastest Java solution in O(1).
Java Solution in O(1)