Company: Deutsche Bank
Difficulty: medium
Maximum Prime Computers understand nothing but binary language, which consists of only zeros and ones. You are given a binary string S . Every non-empty subsequence of S is itself a string of zeros and ones, and can therefore be read as a binary number (leading zeros are simply ignored when the subsequence is converted to a number, so "011" is the number 3). Among all the numbers obtained this way, find the largest one that is a prime number. If no subsequence of S produces a prime number, the answer is -1 . Note: A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. Example Let S = "1011" . Some of its subsequences are "1" , "10" , "11" , "101" , "111" , "011" and "1011" itself. Read as binary numbers these are 1, 2, 3, 5, 7, 3 and 11. The prime values among all subsequences of "1011" are 2, 3, 5, 7 and 11, so the answer is 11 . Function description Complete the solve function provide