Persistent Systems Interview Question for SDE1s
- 0of 0 votes
AnswerCaeser;s Cipher is a very famous encryptiontechnique used in crptography.It is a type of substitution cipher in which each letter in the plaintext is replaced by letter some fixed number of positions down the alphabet.For example,with a shift of 3 ,D would be replaced bt G,E would become H,X would become A and so on.
- ruchitraj93 March 03, 2017 in India
Encryption of a letter x by a shift k can bedescribed mathematically as Ek(X)=(X+K)%26.
Given a plain text and it's corresponding ciphertext,output the minimum no negative value of shift that was used to encrypt the plaintext or else output -1 if it is no possible to obtain the given ciphertext from the given plaintext using caeser's cipher technique.
Input
The first line of the input contains Q,denoting the number of queries.
The next Q lines contain two strings s and t consisting of only uppercase letters
output::
For each test case,output a single non negative integer denoting the minimum value of shift that was used to encrypt the the plaintext or else print -1 if the answer does not exist.
Sample Input OUTPUT
2 3
ABC -1
DEF
AAA
PQR| Report Duplicate | Flag | PURGE
Persistent Systems SDE1
Interview Type: Written Test
3 and -1 are outputs
- ruchitraj93 March 03, 2017