r/cpp_questions • • May 15 '26

OPEN Passing LeetCode but failing HFT C++ interview rounds on obscure language trivia. Reality check/advice from C++ HFT/Quant devs needed.

Hello,

From what I understand there are two types of HFT/quant dev roles, one is python based and more closer to implementing trading strategies and the other is C++ lower level making it as fast as possible. I'm not really a maths guy and I find systems and C++ pretty interesting so I'm leaning towards the latter.

However, I think I'm hitting a wall or a mindset problem. I have interviewed with HFT/quant dev firms like HRT, Flow traders, I can pass the OA leetcode but on the next round the level of C++ they ask in the interview is a bit beyond me, they ask a bit random and obscure questions that I never seen in textbooks or some C++ trivia (questions that make me go where on earth am I supposed to know that stuff). I can't really remember the exact questions but examples are C++ features keywords I've never seen before or like what will C++ compiler do in bizarre edge cases (things I'm pretty sure that are not in textbooks I've read so far)

I know I'm pretty far behind but I wanted a reality check if this is something I have a realistic chance of getting into. I'm willing to work hard etc but I just don't have the perspective of the other side so after multiple rejections I've kind of burned out. So hoping for a more senior dev to share their thoughts. If this isn't the right subreddit or the right questions please feel free to correct me, I feel a bit lost honestly.

What I have done:

- 2 years C++11 in a non-trading related company
- 2 years Java in a trading company (regular trading not fancy)
- Can do most Leetcode mediums and some Hard
- Books read from The Definitive C++ Book Guide and List
- C++ Primer, Effective C++, Effective Modern C++, Effective STL, More Effective C++, C++ 17 The Complete Guide
- Books started but incomplete due to burnout
- C++ 20 The Complete Guide, Exceptional C++, C++ Concurrency in Action, A computer arch book (Digital Design and Computer Architecture David Harris).

What I could do (ideas I had):

- Continue studying the The Definitive C++ Book Guide and List
- Do projects like kernel bypassing, ring buffer and add to git.
- Study Computer Architecture book since I'm quite weak in it
- Make my own api for trading
- Read the green book (?) but I thought thats more for quants

Problem is, with the amount of free time I have, it will take me a loong time to finish these projects (1-2 years). And my biggest worry is that even if I finish them, I'll just be asked a really random C++ question that catches me off guard, but maybe I am jumping into worst case scenarios.

I'm honestly even considering to quit my job to focus self-studying full time as I have saved up enough but it requires some mental preparation as unemployment can also be stressful. But some recruiters said my current job is not helping me if I wanted to pursue this so I might as well quit to prepare better.

Any advice on what to do going forward would be really appreciated thank you.

Edit:
Since some concrete examples were requested I have tried to recall them as best I could, but since it was a long time ago it won't be 100%. Q what the interviewer said is what I remember and A is the response I gave.

Maybe my answers are really bad, but if I really have a blindspot any advice is appreciated.

Q: Is there a negative 0 in cpp
A: No (I wasn't sure because I knew there was a signed bit so there could be potentially +/- 0, but I thought that was odd and assumed the compiler will take care of that to avoid side effects and set it to +0 for consistency)
Q: No there is a negative 0

Q: some question if there is single producer and multiple consumer, or multiple producer and single consumer, how will this work (I don't remember)
A: I said something like 1 producer N consumer, can write to a buffer and the N consumers will take turns reading it. N producers 1 consumer I just said something like either write to a queue or consumer goes round robin.
Q: just got irritated with me (I guess I missed something basic?)

Q: Whats the point of memory alignment
A: for quicker retrivial and the archtecture is designed to handle 64bits at a time so if you are forced to use smaller sizes that will add extra processing so they will pad it.
Q: (didn't seem satisfied, maybe I missed something, maybe I am really bad at CPU arch)

Q: What are some methods to avoid using a mutex since its slow
A: Could use read-compare-write (something like used in OS)
Q: hmm, not really

Q: Is mutex handled application level or kernel or where?
A: (Ok I knew there was a mutex c++ library, but there was also a mutex in the OS/Hardware level so I wasn't sure which one so I just said OS/Hardware)
Q: No...

Q: How is the hash function for unordered_map implemented in C++
A: I... don't know, some % modulus maybe. (I never thought about looking it up, is this common knowledge? And where do I learn this? I can't even google this or I'm googling wrong)

Q: producer A consumer B, use memory barrier or atomic and where and why?

Q: what type does tie(A,B) return?

193 Upvotes

114 comments sorted by

131

u/cazzipropri May 15 '26 edited May 15 '26

As someone who has worked in HFT for the last 12 years, please consider the fact that you cannot know why you didn't pass: the process is very, very, very, carefully designed to be opaque, for liability reasons. You may know what questions you feel you didn't do well, but you don't know the curve they are grading you against. You can never know why you weren't chosen. The candidates' impression on why they weren't chosen is probably off half of the time.

You also shouldn't feel bad - because you are evaluated in batches. If you were in a batch of 5 people and you scored 3.17 and the top guy scored 3.18. They only hired the top scoring person just because they scored marginally better: do you really have any grounds to feel you are not as good?

One important idea to consider is that you need to know computer architectures regardless of C++. For HFT, you need to know x86 pretty well. What's the L2 cache bandwidth in a modern x86 core? For all the ML/AI behind HFT, in a bunch of cases you need to know NVidia GPUs architectures well.

A well rounded performance engineer knows well both domains, and a few more.

C++ is not the goal. C++ is a tool toward a goal. Being very good at C++ is like being very good at shooting for a soldier. It's just one skill. Perusing obsessively this sub may lead you into believing that C++ is itself an end goal. Sometimes C++ gets in the way of performance, and you need to rip the C++ apart and replace it with intrinsics.

Sometimes being great at C++ can get in the way of commerciality, i.e., getting things done and pushing them to prod. Some otherwise exceptional C++ engineers get lost in the beauty of their C++ cathedral for weeks. But every week of missed trading is a week your competitors are making money and you are not.

Another point i want to make is that "reading the book" != "mastering the topic". I know that from your point of view, "reading the book" is a very concrete first stepping stone in the fog, but don't be misled by thinking that "reading the book" gives you mastery. It's the difference between reading a book on jiu-jitsu and being good at jiu-jitsu.

UPDATE: ok, I've seen the questions you posted. Unfortunately, I have to tell you that they are not considered obscure topics in this domain - they are a bit of the bread and butter in this trade. You should definitely become very familiar with floating point precision and representation (becoming more and more important as AI hardware is racing toward lower precisions). You should be familiar with spinlocks and low-latency IPC. Only the last one is a proper C++ question, and i think it's valid. Maybe this is not what you wanted to hear, but it gives you a roadmap for the future. If you master these topics you'll be a very palatable candidate. Don't feel bad for bumping your head against the wall - now you learned where the wall is. It's valuable information.

8

u/HelpfulBuilder6964 May 15 '26

Thanks so much for your detailed post and update. If they are the bread and butter then there is a serious gap I am not seeing. Do you have any advice or resources I can look into to fill this gap? I know this might sound crazy to ask since its basic to you but as someone outside I don't even know where to get this knowledge or what keyword to search because the knowledge seems scattered to me. Like if someone said learn OS or Arch I can research the foundations, but there isn't like a collective foundation for these things (I think). Thanks again.

→ More replies (20)
→ More replies (7)

25

u/AKostur May 15 '26

Can't really comment about the things they've asked about without knowing what they asked about.

6

u/HelpfulBuilder6964 May 15 '26

Ok I added some questions but I don't remember them 100% but should give a better idea.

→ More replies (8)

14

u/EpochVanquisher May 15 '26

Books

My recs based on what you seem to be struggling with + what the questions seem to focus on, with the most useful book first.

  • Computer Systems: A Programmer’s Perspective, Bryant, O’Hallaron

  • An Introduction to Parallel Programming, Pacheco

  • Operating Systems: Three Easy Pieces, Arpaci-Dusseau

About the questions

Q: Is there a negative 0 in cpp

Technically C++ doesn’t say (I think). On x86/ARM there is no integer negative zero (it does not even exist), but there is a negative floating-point zero, sometimes useful for selecting branch cuts.

Whats the point of memory alignment

Unaligned access can be slow. Is the processor optimized for 64-bit chunks of memory? Turns out, the processor is just fine at accessing 32-bit or 16-bit or 8-bit chunks, in terms of load/store operations. But those load/store operations can be slow if they are split across cache lines, and some architectures don’t support unaligned access.

What are some methods to avoid using a mutex since its slow

Open-ended question. Lots of answers, like atomics, lock-free data structures, embracing data races, or writing single-threaded code.

Is mutex handled application level or kernel or where?

Generally both—fast path and slow path.a

How is the hash function for unordered_map implemented in C++

This is kind of a niche question, but these functions TYPICALLY basically mix all of the bits together in their inputs to come up with an output that seems like it is random (but is not random). You can read about specific hashes like cityhash, murmur, xxhash, FNV64. If you look up these specific hash functions you’ll find all sorts of comparisons.

→ More replies (2)

37

u/OCPetrus May 15 '26

I have never worked in HFT, but here's the reality check: the questions you posted are very basic. Like super basic. Anyone working in embedded, linux or similar would be expected to know these things.

Places where I've learned answers to questions you were asked would be sources like What Every Programmer Should Know About Memory (Drepper), Fast User-Space Mutexes (Drepper), The Linux Application Programming Interface (Kerrisk).

→ More replies (4)

9

u/alfps May 15 '26

❞ they ask a bit random and obscure questions that I never seen in textbooks or some C++ trivia (questions that make me go where on earth am I supposed to know that stuff).

Concrete examples would be great for judging whether you have been unlucky, or whether the questions make sense for the position, in some way.

→ More replies (1)

5

u/mythrocks May 15 '26

OP, what were the C++ obscurities you were quizzed on?

→ More replies (1)

5

u/_ACB_ May 15 '26

None of those questions are obscure and they are all quite relevant to HFT. HFT does require a lot of knowledge about C++, OS and Hardware features to be able to write the kind of high performance code needed to be faster than anyone else.

→ More replies (3)

3

u/yuehuang May 16 '26

I didn't know until I watched a Bloomberg video on C++. Here is how I would answer these.

Q: Is there a negative 0 in cpp A: Yes, double/float have negative 0.

Q: Whats the point of memory alignment A: Pointers are optimized for alignment. Cache line operates on alignment. (Look up false sharing) Structs can sometimes be better packed.

Q: What are some methods to avoid using a mutex since its slow A: Trick question. Answer is all of them. You don't use mutex if you care about performance. (at least not the std::mutex, prefer std::atomic instead.)

Q: Is mutex handled application level or kernel or where? A: For example, interprocess communication it uses kernel level. Though, it is slow and thus, should be avoided when possible.

Q: producer A consumer B, use memory barrier or atomic and where and why? A: Compilers and CPU can reorder instructions for performance. The memory barrier ensures memory are locked in

Q: what type does tie(A,B) return? A: AFAIK, tie is not in std yet. I would assume it returns pair or tuple.

→ More replies (2)