• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

Tips for an entry level C++ quant dev interview

Joined
11/5/14
Messages
294
Points
53
Hi friends,

I am interviewing for an entry level C++ quant developer role. My initial screening round was decent, it had basic math questions and a puzzle. I was told by the interviewer, if I made it, this would be followed by a four hour video conference round(as the position is based out of another country), that involves algorithmic thinking and math & puzzles.

What do you think I should expect? I expect to have 2-3 weeks to prepare. What are some helpful sources I could skim through specifically for algorithms? (I have an old copy Cormen Liserson Rivest). I am from a CompSci background, but I need to brush up. Any specific tips would be really really helpful.

As far as math is concerned, I'd expect questions from Calculus/linear algebra.


Thanks,
Quasar.
 
All the usual: Cracking the Coding Interview, Leetcode etc. It's difficult to give more specifics without knowing what kind of role this is. Can you maybe list a few similar companies if not the company you're applying to? What does Glassdoor have as typical questions?
 
All the usual: Cracking the Coding Interview, Leetcode etc. It's difficult to give more specifics without knowing what kind of role this is. Can you maybe list a few similar companies if not the company you're applying to? What does Glassdoor have as typical questions?

Thanks for sharing this. I never knew about Cracking the Coding Interview and Leetcode. Those are nice. I'll be sure to search Glassdoor.
 
If you already have a DSA background you may not learn much from these books but I think they're worth reading for those who don't or are a bit rusty:

Bhargava's Grokking Algorithms, and

Roughgarden's Algorithms Illuminated: Part 1 (with three more in the pipeline).
 
Thanks for sharing this. I never knew about Cracking the Coding Interview and Leetcode. Those are nice. I'll be sure to search Glassdoor.
For algorithms I would suggest you go on Leetcode and you do as many as you can from data structures, arrays and strings, and math related stuff (reverse digital of big number, implement power or sqrt of 2, etc.)

Additionally, good idea would be to review certain math operations and their complexity, and code them: multiply matrices, write a class to compute the nth derivative of a polynomial, etc.)

Also memory management is always present, so you might want to review pointers and pointer wrappers, how to write custom garbage collectors for your data structures and dynamic memory allocators (including binary trees and linked lists)
 
Pavlos,
STL algorithms as well?
Definitely. The more C++11/14 and standardized solutions, the better. Though it's good to practice with old C style structures as well, cause if they ask you to reverse a singly linked list, your input will be some Node* haha. Same for binary trees and perhaps hash tables. Should know the STL equivalents as well.

That said, if your solution includes STL, they might ask intuitive questions about implementations of the STL algorithms and data structures to see how deep your understanding is, and vice versa for primitive implementations.

Leetcode is a good place to practice both.
 
Definitely. The more C++11/14 and standardized solutions, the better. Though it's good to practice with old C style structures as well, cause if they ask you to reverse a singly linked list, your input will be some Node* haha. Same for binary trees and perhaps hash tables. Should know the STL equivalents as well.

That said, if your solution includes STL, they might ask intuitive questions about implementations of the STL algorithms and data structures to see how deep your understanding is, and vice versa for primitive implementations.

Leetcode is a good place to practice both.

Thank you so much @Pavlos Sakoglou , @bigbadwolf . :) I am a little rusty on DSA. I am onto it quickly and am going to try and give my best shot at this.

I gathered from your replies, I must review :
  • Data structures - Stacks, queues, linked lists & binary trees, good to implement these using STL containers in C++. Also, run through STL algorithms in C++.

  • Algorithms - Math operations e.g. adding two large numbers, matrix multiplication etcetera, and their efficiency. Any other references (book) for these? Leetcode is awesome for practice. In the interest of time, any book or reference would kinda be structured learning. Strings are another favorite.

    I get the picture, that I should not spend too much time for the typical Comp Sci operations - such as sorting, tree traversals (BFS,DFS) etc. Would that be correct?
 
Thank you so much @Pavlos Sakoglou , @bigbadwolf . :) I am a little rusty on DSA. I am onto it quickly and am going to try and give my best shot at this.

I gathered from your replies, I must review :
  • Data structures - Stacks, queues, linked lists & binary trees, good to implement these using STL containers in C++. Also, run through STL algorithms in C++.

  • Algorithms - Math operations e.g. adding two large numbers, matrix multiplication etcetera, and their efficiency. Any other references (book) for these? Leetcode is awesome for practice. In the interest of time, any book or reference would kinda be structured learning. Strings are another favorite.

    I get the picture, that I should not spend too much time for the typical Comp Sci operations - such as sorting, tree traversals (BFS,DFS) etc. Would that be correct?
These data structures you listed are already implemented as STL containers, so learn how to use them (their basic member functions) and if you have time learn how implement at least one or two of them in native C++ so you can gain intuition on what is happening when you construct an std::vector or an std::unordered_map.

The Bible of algorithms in my opinion is "Introduction to algorithms" by CLRS, though it assumes no background and chapters are quite elaborate. It would be helpful to review the first 10-15 chapters, if you can skim over them quickly. But perhaps it will be more helpful to go to cppreference documentation page and read about STL algorithms instead.

Good to know at least one sorting algorithm. Also integer conversion to binary is interesting, and vice versa. Tree traversals with recursion came up once or twice in my interviews recently, so if you have time it might be good to know. Also strings.
 
On the integer to binary conversion, is an algorithm(hack) like this acceptable? This was the easiest solution I had in mind.

C++:
#include <iostream>
#include <string>
#include <cmath>
#include <climits>

int main() {

    long long n = 1023;

    const int no_of_bits = sizeof(long long) * CHAR_BIT;
    int arr[no_of_bits] = { 0 };

    for (int i = no_of_bits - 1; i >= 0; i--)
    {
        arr[i] = ((n >> i) & (0x0001));
        std::cout << arr[i];

        if (i % 4 == 0)
            std::cout << "\t";
    }

    std::cin.get();
    return 0;
}
 
Last edited:
That's neat!

I made it through the first screening round. I wish to prepare hard for the final assault! I want to practice, practice and practice in the next few days.
Since you are going down that path, and irregardless of the results of your interviews, you should consider taking the courses here -- you will find them tremendously helpful in your career.
For example, std::bitset is extensively covered in the advanced course along with many many other useful classes and algorithms that come up often.
 
Thanks @Pavlos Sakoglou . A diamond that looks so resplendent today, was once in very inhospitable conditions, under tonnes of debris in the bowels of the earth. I think I am pretty much like that raw stone right now. :) Determined to botch up my programming & modelling skills and math knowledge through the open university math bachelors and courses here.

Absolutely, I am considering taking courses in C++ and PDEs here.
 
To begin with, I coded some program to work with stacks - using native C-style structs. I will rebuild them using class templates and move on to practising queues & lists. Made some quick notes.
 

Attachments

  • Data Structures.pdf
    152.2 KB · Views: 123
Hi Daniel, thanks for leading me to the standard CPP reference for stacks.

I have built my own QPArray class - that simulates a fixed sized array. I intend to pass it as a template parameter to QPStack - the container that will be the home for stack elements. I tried testing QPArray. While the code works well, for integers, I have two questions, I was hoping someone could answer. I tried searching the internet, but haven't found any references.

  1. How do I initialize QPArray<T,N> object using a list initializer? For example, I am interested to write

    C++:
    QPArray<T,N> arr = {1,2,3,4,5};

  2. Why doesn't << operator work when I construct an array std::string's? I thought that << is already overloaded to handle objects of this type.

  3. Any design tips/improvements would be immensely helpful.

TestQPArray.cpp

C++:
#include <iostream>
#include "QPArray.h"

int main()
{
    QPArray<int, 5> arr1;
    arr1[0] = 1;
    arr1[1] = 2;
    arr1[3] = 3;
    arr1[4] = 4;
    arr1[5] = 5;

    std::cout << arr1.at(3) << std::endl;

    std::cin.clear();
    std::cin.get();
    return 0;
}

QPArray.h

C++:
#ifndef QPARRAY_H
#define QPARRAY_H
#include <cstring>

template <class T, std::size_t N>
class QPArray
{
private:
    T* items;
    int maxsize;
public:
    /*Constructors and destructors*/
    QPArray();
    QPArray(const T value);
    QPArray(const QPArray<T, N>& a);
    virtual ~QPArray();

    /* Overload = operator*/
    QPArray<T, N>& operator =(const QPArray<T, N>& a);

    /* Selectors - Element access*/
    T& at(int index);
    T& operator [](int index);
    T& front();
    T& back();
  
    /* Capacity*/
    bool empty();
    virtual int size();
    virtual int max_size();

    /*Operations*/
    QPArray<T, N>& fill(T value);
};

template <class T,std::size_t N>
QPArray<T, N>::QPArray()
{
    if (N > 0)
    {
        items = new T[N];
    }
    maxsize = N;
}

template <class T, std::size_t N>
QPArray<T, N>::QPArray(T value)
{
    maxsize = N;

    if (N > 0)
    {
        items = new T[N];
        for (int i = 0; i < maxsize; i++)
        {
            items[i] = value;
        }
    }
}

template <class T, std::size_t N>
QPArray<T,N>::QPArray(const QPArray<T, N>& a)
{
    maxsize = a.maxsize;
    items = new T[maxsize];
    for (int i = 0; i < maxsize; i++)
        items[i] = a.items[i];
}

template<class T, std::size_t N>
QPArray<T, N>::~QPArray()
{
    if(N > 0)
        delete[] items;
}

template<class T, std::size_t N>
QPArray<T, N>& QPArray<T, N>::operator =(const QPArray<T, N>& a)
{
    if (this == &a)
        return *this;

    if (maxsize != a.maxsize)
        throw std::runtime_error(std::string("Src and target array bounds do not match"));

    for (int i = 0; i < maxsize; i++)
    {
        items[i] = a.items[i];
    }

    return *this;
}

template <class T, std::size_t N>
T& QPArray<T, N>::at(int i)
{
    return items[i];
}

template <class T, std::size_t N>
T& QPArray<T, N>::operator [](int index)
{
    return items[index];
}

//Access the first element of the array
template <class T, size_t N>
T& QPArray<T, N>::front() {
    return items[0];
}

//Access the last element of the array
template <class T, std::size_t N>
T& QPArray<T, N>::back() {
    return items[maxsize - 1];
}

template <class T, std::size_t N>
bool QPArray<T, N>::empty()
{
    if (maxsize == 0)
        return true;
    else
        return false;
}

template <class T, std::size_t N>
int QPArray<T,N>::size()
{
    return maxsize;
}

template <class T, std::size_t N>
int QPArray<T, N>::max_size()
{
    return maxsize;
}

template <class T, std::size_t N>
QPArray<T, N>& QPArray<T, N>::fill(T value)
{
    for (int i = 0; i < maxsize; i++)
    {
        items[i] = value;
    }

    return *this;
}


#endif // !ARRAY_H
 
Last edited:
I included <cstring> and forgot to include <string>. After including the correct header file, [2] got resolved. :)
 
This code looks wrong. On the one hand it is a fixed-sized stack but internally it uses heap. Beware learning bad programming habits.

Your code is a mix of C and C++. Confusing.
 
Back
Top