Welcome Learners, in this post, you will know about problem statement given in my interview with Infosys. Please do refer my previous post Infosys Interview Experience – PP role if you need the complete experience.
In this post I’ll explain about the problem statement and the way I solved the problem. The remaining experience and the questions asked had mentioned in the post mentioned above. So do refer to the previous post before proceeding with this.
Infosys interview Problem Statement
The interviewer gave me a problem statement by sharing his screen. He shared his screen and asked me to solve the problem within 45 minutes. It is of easy level. It hardly took 15 minutes to solve and write the code.
A string and no. of columns are given to you.. And you need to decrypt it. The string is encrypted in the way mentioned below
Let us suppose the string is thisisapostrelatedtoinfosysinterview. Then you can write this string in the matrix as follows. You need to fill the remaining column with random alphabets at the end.
And you read this text from left to right and right to left alternatively row wise. You have this string now. And you need to trace back the original string and print it. So you need to decrypt the given string. You have to print the string along with the random alphabets filled at the end.
Solution in python
The solution is of bruteforce. I wrote the given string back to the original form in the matrix and read it column wise. I printed it at the end. To store it in the matrix, I used a flag variable to keep track with the direction of reading i.e. left to write and right to left alternatively.
So guys, this is the problem statement and the solution for it. Prepare well and rock you interview. All the best Learners.
Don’t stop your learning, because there is so much to learn in this world. Do refer geeksforgeeks for your preparation.