Status: New CS grad from #11 CS school in US
Position: Entry Level C++ Software Engineer
Location: Remote
Date: March 14th, 2023
Feb 13th: Online coding assessment
I applied for the job and got an almost immediate reply asking me to take a basic IQ/verbal/math test + personality test as well as a coding assessment. Not gonna post details or my solution here but it was a basic stock market problem. Assessment had a deadline of a week so I focused on making it super readable. Apparently my code and test scores were good enough for next round.
Feb 27th: Prescreen (30 min)
Virtual call talking to a "hiring manager" who was clearly a solid dev. Questions were mostly pertaining to my conceptual understanding of C++. He went through my code in front of me and made a few notes about how I used pass-by-reference in a case where it was inefficient, which I readily admitted to. He dug into this mistake by asking me what pass-by-reference was and I said it was like a pointer which he brought up more details about. He mentioned that I would be asked to go line-by-line through my original code in the next round. He very briefly mentioned templates (foreshadowing), which I said I had used before but not a ton. He asked about low-level programming and multi-threading/distributed systems which are topics I took classes on and talked about a little bit. This might have just been a test of whether I actually wrote my submitted code.
Things I did as prep for the next round:
March 14th: Virtual Technical Interview (2.5 hr)
Virtual call where I was spoke with 3 interviewers
Coding Assessment Review:
After saying hi and them introducing themselves, I was asked to explain my code. I maybe should have done a stronger introduction of myself and my experience here but the senior engineer had network issues right at that moment so I felt uncomfortable doing so. I spoke for maybe 5 minutes describing my code and explaining the thought/design process behind it. I mentioned the time complexities of my algorithms and a few improvements I could make (one case should have used map.find() directly instead of calling map[]). They didn't ask many questions that I had expected like how to improve the complexity or etc (which was possible and I had prepared answers for). They pointed out a few flaws, e.g. I used namespace std, I didn't initialize some variables to zero by default and wrote a default constructor instead, I passed by reference/value inefficiently.
Question 1:
#include <stdlib.h>
#include <iostream>
int atoi(const char* ptr, int n) { }
int main() {
char buffer[] = "B0000000999999999";
const char* ptr = buffer+1;
int qty = atoi(ptr,10);
std::cout << qty << '\n';
return 0;
}a) Complete the atoi() function, you will only receive non-negative numerical input
I completed the function reasonably quickly:
int atoi(const char* ptr, int n)
{
int ret = 0;
for (int i = 0; i < n; i++) {
ret *= 10;
ret += *(ptr+i) - '0';
}
return ret;
}b) They asked me to test this function. I tried a few inputs but said that assuming nice input the only real concern was values larger than INT_MAX whence you would encounter overflow.
c) They asked me about how I would make this faster if I knew something about n at compile time.
This was a question I was unprepared for. I told them I was trying to look for ways to make the crux lines faster.
ret *= 10; ret += *(ptr+i) - '0';
They suggested I look somewhere else for an improvement. I eventually had to admit I did not know. They asked me if I had heard of "loop unrolling". I told them that I hadn't. They explained it to me and then asked me to unroll the loop if n == 2.
int atoi(const char* ptr)
{
int ret = *(ptr) - '0';
ret *= 10;
ret += *(ptr+1) - '0';
return ret;
}They then asked me to find a way to let the compiler know to unroll the loop at compile time. I suggested overloading the function. They asked for a more general method. After a bit, they told me templates are the answer. This did not enable me to solve the problem since I thought templates were essentially equivalent to overloads.
Realizing that I did not understand, they asked me to implement the function using a template essentially as an overload which I did but am not including here out of shame. Then they explained to me how to solve the problem properly using templates:
template <int T> // I've only ever seen: template <typename T>, didn't know this existed lol
int atoi(const char* ptr)
{
int ret = 0;
for (int i = 0; i < T; i++) {
ret *= 10;
ret += *(ptr+i) - '0';
}
return ret;
}
int main() {
char buffer[] = "B0000000999999999";
const char* ptr = buffer+1;
int qty = atoi<10>(ptr);
std::cout << qty << '\n';
return 0;
}Question 2: There was another question tab in their HackerRank tab but they never opened it, maybe because I didn't do the template question right.
Last 30-ish minutes: Immediately after I failed to answer the template question correctly, the senior engineer asked me something very close to: "What real C++ experience do you have? You don't know what templates are, are you just nervous or what?" I proceeded to talk about my resume and coursework in C++ and said that I hadn't used templates that much in my programming. I didn't explain exactly how I had used templates before and say that I didn't know about this use case which I think I should have said. Then they asked a lot of typical interview questions about my knowledge and resume and why I wanted to work there. I fielded these questions alright on the whole I think. I had prepared reasonably decent answers for them.
March 22nd: Rejection Email
:(
My takeaways for interviewing:
My takeaways for prep:
Note: The resume I got interviewed with was admittedly really bad and did not show what I've done very much at all, which is something I fixed.
Thank you for reading, writing this was greatly therapeutic.
EDIT:
As discussed below, here is a clean solution to the atoi problem which uses recursion with the template which I learned something from.
template<int N>
int atoi(const char* ptr) { return atoi<N-1>(ptr-1)*10 + (*ptr - '0'); }
template<>
int atoi<0>(const char* ptr) { return (*ptr - '0'); }