Facebook interview question(Rotational Cipher)

Kristinelpetrosyan
2 min readJan 31, 2021

--

Moving forward in my job search I got many technical interviews coming and one of them and I would say the most difficult is Facebook. They give 40 minutes for 2 problems and each one 18–20 minutes. They don’t give a chance to run the code and see whether the test cases will pass. You have to do everything manually and check the test by explaining and going over the code.

One of the problems I would like to share here with you is Rotational Cipher:

One simple way to encrypt a string is to “rotate” every alphanumeric character by a certain amount. Rotating a character means replacing it with another character that is a certain number of steps away in normal alphabetic or numerical order. For example, if the string “Zebra-493?” is rotated 3 places, the resulting string is “Cheud-726?”. Every alphabetic character is replaced with the character 3 letters higher (wrapping around from Z to A), and every numeric character replaced with the character 3 digits higher (wrapping around from 9 to 0). Note that the non-alphanumeric characters remain unchanged.Given a string and a rotation factor, return an encrypted string.

Solution:

Hope this was helpful and if you have any question please feel to contact me @kristinelpetrosyan@gmail.com.

--

--

Kristinelpetrosyan
Kristinelpetrosyan

Written by Kristinelpetrosyan

Data Science student @Flatiron-School

Responses (1)