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.
If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below:
my solutions
fnsum_xor(n:i64)->i64{// Time complexity: O(log(n))// Space complexity (ignoring input): O(1)letmutn=n;letmutzeros_in_binary=0;whilen>1{ifn&1==0{zeros_in_binary+=1;}n=n>>1;}// The answer is that the number can have 1 or 0 in the positions where 'n' has 0, so 2 to the nreturn1<<zeros_in_binary}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sum vs XOR
You are viewing a single comment's thread. Return to all comments →
Rust best solution
If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions