Experiences with coding - Coding Interview (w.cipher)
Published: 2020-09-12 19:06:35

So I had a live coding interview the other day. I was pretty excited for it because I haven't had too many live. I have had my fair share of take home ones and I have done pretty well on them for the most part. Generally the format of take home coding challenges (from my limited experience) is the company will send you a link to some third party like coderpen or hackerrank or something. These are online IDEs that will have algorithm challenges and maybe other types of problems but I have only had algorithm problems, personally.  

They will have basic instructions which will generally just have a time limit. Ive had ranges of 1 algorithm with 4 hours of time to 4 algorithms of 70 minutes. The annoying thing for me personally about some of these take home challenges is that many times I would complete the whole take home challenges, and my code would be quite clean and efficient. Maybe they wouldn't be the absolutely most optimal way, but at least good enough to get some sort of consideration, and I would never get called back, yet on the other hand sometimes I wouldn't complete the problem and be all over the place with my code and I would get that callback. My point is that you cannot predict these things so don't get too depressed if you don't complete coding challenges. 

Anyways I had my live coding challenge the other day. This was the second step for a company that I will not name. I had a take home challenge that was difficult but I managed to get it done in about an hour and 30 min. When I got the email that I was getting invited to the second interview I was stoked for obvious reasons. It is hard for someone like myself with no actual work experience and a totally unrelated degree to even get a second look from people without some sort of introduction. Sadly I didn't take advantage of the situation as well as I could have. The email had a pdf that explained what to do to prepare for interview. It said to go over data structures like graphs, binary trees, arrays, objects, etc. The basics. The part that I was really paying attention to was the explanation of the interview. It said the interview would be a mix of coding and talking about a past project. 

The interview was an hour long and started as the interviews generally do. The proctor told me about themself in about 1-3 minutes, and I did the same. With only an hour we didn't have time to chit chat. I thanked them for their time and we went into the algorithm problem. Including the explanation which was read to me and then given in a comment, it took me roughly 7 minutes to even make sure that I was understanding the problem. That is always an annoying part of algorithm problems. Sometimes they are worded poorly. And I always make sure with my interviewer that I am understanding correctly so that I don't waste time down the line. Then I took another 3 minutes roughly to explain what my strategy was going to be. 

The problem was pretty simple to be honest, although I am probably going butcher the explanation. There were 3 inputs, a string, and two numbers representing rows and columns - r and c. The output was a coded message. The type of cypher was described to me as a 'route' cypher. I do not know if that is a true thing or if it was made up for the algorithm. Essentially the way the cypher works is that the message would be encoded by the cypher by first breaking the message into a grid of characters including white spaces rxc. So a square/rectangle would be made by the characters, spelling out the messaged from left to right. Then the coded message would be made by going down the columns instead of the rows and outputting a coded message which is essentially just the message all jumbled up. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/c9d47auwjmahj8kjtywn.jpeg)

So the first thing I wanted to do was make the grid. This took me a long time. I am currently shaking my head because this problem is really not very hard. I generally dont have these kind of issues but for some reason I was daunted by the fact that I was being observed coding. Every time I would take a second to consider what I was doing, I would get self conscious. I would remember what everyone told me in preparation for coding challenges; to make sure that I was constantly talking about what I was thinking and to not clam up. Then I would start babbling about what I was thinking and that would distract me further. I got stuck many times and had to console log constantly. With an algorithm like this (which I was using a nested loop for) it is hard for me to visualize without console logging often. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/aw22825p860tp21ena83.jpeg)

After finally getting the grid working I started setting up my second nested loop. I need to do this to go through the columns then rows to build up the message. As I was writing this out I ran out of time. I am confident that with 5-10 more minutes I would have completed it. However, I am still extremely frustrated with myself for not being able to complete it during the interview. I am going to make sure that I continue to practice and make sure that I prepare for the situation again. While I have not yet heard back from this company, I do not have high hopes considering I didnt finish such a trivial problem. By getting around my bugs I think I showed a bit of decent problem solving skills but other than that I did not show nearly what I can do with code. 

The interviewer was very nice and gave me some great advice and input. If I were to offer any advice to myself or other persons waiting for this type of interview, I would say to just practice, practice, practice. Also try to practice in a way that simulates the interview, because coding alone without an distractions is one thing, but coding under observation is another. Especially with the stress of knowing that this could be your only shot at making it at the company. If anyone was curious, this is my working code that I wrote later. Took me about 15-20 minutes. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bjmpv3amwmye14brastn.jpeg)