Summary
I had an interview at Arista Network focusing on C++ pointer concepts, including debugging code and fixing logical errors to achieve a desired output. I successfully navigated both parts of the problem.
Full Experience
My interview at Arista Network began with a C++ debugging problem. The interviewer presented me with a code snippet involving pointers and asked me to predict its output and explain the reasoning. I correctly determined that the output would be 'Value: 10' and explained that the function receives a copy of the pointer, so reassigning p within the function does not affect the original ptr in main. Following this, I was challenged to modify the function to make the program print 'Value: 100'. I proposed dereferencing p and assigning the value of x to the memory location it pointed to, thereby altering the value of a in main to 100.
Interview Questions (2)
What will be the output of the provided C++ code snippet and why?
#include <iostream> using namespace std;void function(int *p) { int x = 100; p = &x; }
int main() { int a = 10; int *ptr = &a; function(ptr); cout << "Value: " << *ptr << endl; return 0; }
Given the previous C++ code snippet, how would you modify the function to make it print Value: 100 instead of Value: 10, by changing only the function body?
Original function:
void function(int *p) {
int x = 100;
p = &x;
}
Summary
I recently interviewed with Arista Network for a first-round technical position where I confidently solved two coding problems. Despite my strong performance, I was unfortunately rejected, with HR citing alleged struggles which I believe were entirely unfounded.
Full Experience
I recently completed my first-round interview with Arista Network. The interview was conducted by a principal engineer and primarily focused on two coding questions. I was presented with the problem Remove Linked List Elements, which I successfully solved within 10 minutes, achieving an optimal O(N) time complexity and O(1) space optimization.
The second question I tackled was Remove All Occurrences of a Substring. For this problem, I demonstrated two distinct approaches: one utilizing C++ Standard Template Library (STL) features and another purely iterative method. Both solutions maintained an overall time complexity of O(N). Throughout the coding session, I made sure to run all test cases provided by the interviewer and thoroughly discussed various corner cases for both problems.
Following the technical segment, we transitioned into a positive discussion regarding my current project. It's worth noting that I was not feeling well on the day of the interview, yet I still joined the call and believe I effectively completed all the Data Structures and Algorithms problems.
However, the feedback I subsequently received from HR indicated that Arista Network was not inclined to move forward with my application. They stated that I was supposedly unable to solve the second question and struggled with basic problem-solving skills. I find this feedback entirely baseless and believe the interviewer may not have fully comprehended my C++ code. As a candidate, I put significant effort into preparing for interviews, and such inaccurate assessments can be incredibly disheartening.