Question 1: Subarray Product Less Than K
Question 2: Enigma - The Cipher Machine
Following the principles of Enigma, a modified Enigma machine is developed having rotorCount rotors labelled from 1 to rotorCount . Each rotor has value that can be set between minRotorVale and maxRotorValue , both inclusive. To make this machine work, the values set in the 2nd through rotorCount should have a greatest common divisor with rotor 1 of 1. In other words, they should be set to a number that is coprime with the setting of rotor 1. Calculate the number of possible configurationin which rotor can be set.
RotorCount = 3, minRotorValue = 2, maxRotorValue = 3
Possible Combination = (2,3,3), (3,2,2), (3,2,4), (3,4,2), (3,4,4), (4,3,3)
All other combination are invalid, as they are not coprimes with rotor 1.
Input Type: RotorCount, minRotorValue, maxRotorValue
Output: No of valid combinations
Sample Input1: 2, 1, 3
Sample Input 2: 3, 2, 6