Day 4/90: HFT Prep – Navigating Rotated Arrays & Memory Reallocations

Search for a command to run...

No comments yet. Be the first to comment.
Let’s be real: some days of development are 10% coding and 90% fighting your tools. Day 7 was exactly that—a mix of OBS audio tuning, "Day 1" algorithm logic, and deep-level C++ concurrency. Check the live session here: Watch on YouTube 🎙️ The "Pre...

In the world of software development, we often talk about "clean code" and "optimal algorithms" in a vacuum. But for many developers, coding doesn't happen in a sterile lab; it happens amidst system crashes, environmental frustrations, and the weight...

Watch the Day 5 raw log here: https://youtu.be/Kh3lQ0drC8Y The Pursuit of Discipline I’ll be honest: today was a rough day and my mood was quite off. I faced setbacks with two Online Assessments (OAs)—one for Milliman that didn't go well and another ...

Watch the Day 3 raw log here: https://youtu.be/Mcia2gwFWfA The Pursuit of Discipline I’ll be honest: I struggled with procrastination yesterday. I realized my previous 40-minute videos were too long to be sustainable logs, so I'm shifting to more foc...

On this page
Watch the Day 4 raw log here: https://youtu.be/TNzKKlwQrYM
Day 4 is about refining the "Signal." In high-frequency trading, every nanosecond counts, and today I focused on how both our algorithms and our choice of data structure management impact latency. I’m continuing to use my digital tablet setup to practice "whiteboarding" my thought process—it’s a raw way to ensure I can communicate complex logic clearly under pressure.
The "Rubber Duck" Breakthrough
As always, Mr. Pengu was there to "interview" me as I worked through the logic. I spent some time troubleshooting my recording setup to ensure a steady frame rate for the live coding segments.
I tackled the Search in Rotated Sorted Array problem (LeetCode 33).
1. The Problem Statement
Given an integer array nums sorted in ascending order with distinct values, which is then possibly rotated at an unknown pivot index k, find the index of a target value.
O(N)): A linear search checking every element.O(log N)): Even in a rotated array, one half (either left or right of the midpoint) is always sorted. By identifying the sorted half and checking if the target lies within its range, we maintain binary search efficiency.2. The Logic
low + (high - low) / 2.nums[low] with nums[mid].3. The HFT "Gotcha": `std::vector::reserve`
I spent about 30 minutes analyzing the hidden costs of std::vector.
v.reserve(n) to allocate memory upfront. This prevents multiple reallocations and unnecessary data movement during push_back operations, which is critical for low-latency systems.Current Status: 4/90 Days Complete
I'm starting to see the connections between basic DSA and hardware-level performance. Mastering these reallocations and boundary conditions is the only way to handle the high-pressure questions asked by firms like Graviton or Tower Research.
#HFT #CPP #BinarySearch #90DayChallenge #MAIT #FedoraLinux