Summary
I participated in the Citadel Securities Online Assessment for a C++ Engineer role. The task involved refactoring complex C++ code to improve its time complexity, specifically solving a problem to find the maximum difference between elements x[i] - x[j] where j <= i within a 1.5-hour time limit.
Full Experience
I recently took the Online Assessment for a C++ Engineer position at Citadel Securities. The assessment was a challenging 1.5-hour task focused on refactoring existing, complex C++ code. A significant part of the challenge involved identifying misleading variable names and deceptive logic. For instance, some variables were named to suggest graph structures when none existed, and tricks like casting and bit shifting were used instead of simple x >= 0 checks, or squaring and then taking a square root instead of a direct a >= b comparison. The core algorithmic problem I needed to optimize was finding the max(x[i] - x[j]) where j <= i. I was required to reduce the initial O(n2) complexity to an O(n) solution.
Interview Questions (1)
The primary algorithmic challenge was to implement a function that finds the maximum value of x[i] - x[j] from a given array x, with the constraint that the index j must be less than or equal to i (j <= i). The initial implementation presented was O(n2) and needed to be optimized to achieve O(n) time complexity.