## Recursive Digit Sum

We define super digit of an integer x using the following rules: Given an integer, we need to find the super digit of the integer. If x has only 1 digit, then its super digit is x. Otherwise, the super digit of x is equal to the super digit of the sum of the digits of x. For example, the super digit of9875 will be calculated as: super_digit(9875) 9+8+7+5 = 29 super_digit(29) 2 + 9 = 11 super_digit(11) 1 + 1 = 2 super_digit(2) = 2 Function Description Co

View Solution →## Flipping bits

You will be given a list of 32 bit unsigned integers. Flip all the bits ( 1 -> 0 and 0 -> 1 ) and return the result as an unsigned integer. Function Description Complete the flippingBits function in the editor below. flippingBits has the following parameter(s): int n: an integer Returns int: the unsigned decimal integer result Input Format The first line of the input contains q, the number of queries. Each of the next q lines contain an integer, n, to process. Constrai

View Solution →## Time Complexity: Primality

A prime is a natural number greater than 1 that has no positive divisors other than 1 and itself. Given p integers, determine the primality of each integer and return Prime or Not prime on a new line. Note: If possible, try to come up with an primality algorithm, or see what sort of optimizations you can come up with for an O(n) algorithm. Be sure to check out the Editorial after submitting your code. Function Description Complete the primality function in the editor below. prima

View Solution →## Friend Circle Queries

The population of HackerWorld is 10 ^ 9. Initially, none of the people are friends with each other. In order to start a friendship, two persons a and b have to shake hands, where 1 <= a, b <= 10^9. The friendship relation is transitive, that is if a and b shake hands with each other, a and friends of a become friends with b and friends of b. You will be given q queries. After each query, you need to report the size of the largest friend circle (the largest group of friends) formed after co

View Solution →## Maximum Xor

You are given an array arr of n elements. A list of integers, queries is given as an input, find the maximum value of queries[ j ] each arr[ i ] for all 0 <= i < n, where represents xor of two elements. Note that there are multiple test cases in one input file. Function Description Complete the maxXor function in the editor below. It must return an array of integers, each representing the maximum xor value for each element queries[ j ] against all elements of arr. maxXor has t

View Solution →