title-img


Abbreviation

You can perform the following operations on the string, a: 1.Capitalize zero or more of a's lowercase letters. 2.Delete all of the remaining lowercase letters in a. Given two strings, a and b, determine if it's possible to make a equal to b as described. If so, print YES on a new line. Otherwise, print NO. For example, given a = AbcDE and b = ABDE, in a we can convert b and delete c to match b. If a = AbcDE and b = AFDE, matching is not possible because letters may only be capitalized or

View Solution →

Prime XOR

Penny has an array of n integers, [a0,a1, a2, ...., an-1]. She wants to find the number of unique multisets she can form using elements from the array such that the bitwise XOR of all the elements of the multiset is a prime number. Recall that a multiset is a set which can contain duplicate elements. Given q queries where each query consists of an array of integers, can you help Penny find and print the number of valid multisets for each array? As these values can be quite large, modulo each

View Solution →

Decibinary Numbers

Let's talk about binary numbers. We have an n-digit binary number, b, and we denote the digit at index i(zero-indexed from right to left) to be bi. We can find the decimal value of b using the following formula: (b)2 => bn-1.2^(n-1) + ... + b2 . 2^2+ b1.2^1 + b0.2^0 = (?)10 For example, if binary number b = 10010, we compute its decimal value like so: (10010)2 => 1.2^4 + 0.2^3 + 0.2^2 + 1.2^1 + 0.2^0 = (18)10 Meanwhile, in our well-known decimal number system where each digit ranges f

View Solution →

Fair Cut

Li and Lu have n integers, a1,a2, ...,an, that they want to divide fairly between the two of them. They decide that if Li gets integers with indices I = {i1, i2, ..., ik} (which implies that Lu gets integers with indices J = {1, 2, ...,n}\I), then the measure of unfairness of this division is: f(I) = Σ(i∈I) Σ(j∈J)|ai-aj| Find the minimum measure of unfairness that can be obtained with some division of the set of integers where Li gets exactly k integers. Note A\B means Set complement

View Solution →

The Maximum Subarray

We define subsequence as any subset of an array. We define a subarray as a contiguous subsequence in an array. Given an array, find the maximum possible sum among: 1.all nonempty subarrays. 2.all nonempty subsequences. Print the two values as space-separated integers on one line. Note that empty subarrays/subsequences should not be considered. Example arr = [-1, 2, 3, -4, 5,10] The maximum subarray sum is comprised of elements at inidices [1-5]. Their sum is 2 + 3 + -4 +5 + 10 =

View Solution →