Skip to main content

Command Palette

Search for a command to run...

Day 5 of 90: Effective HFT Prep with the Two-Pointer Technique and Overcoming Difficulties

Updated
2 min read
Day 5 of 90: Effective HFT Prep with the Two-Pointer Technique and Overcoming Difficulties
S
Documenting my daily learnings as I prepare for SDE-1 roles at high-performance and HFT-focused companies. Passionate about systems, strong DSA, and building efficient backend infrastructure.

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 for Salesforce that featured complex DP and Graph questions. However, in HFT, discipline means showing up and documenting the grind even when things aren't going your way.

The Internship Grind

Despite the personal setbacks, I maintained my professional momentum. I put in over 3 hours of work on my remote internship, successfully completing three TypeScript tasks and getting my Pull Request merged.


Technical Deep Dive: Two Sum II (Sorted Array)

Today's focus was on LeetCode 167, which is a more constrained version of the classic Two Sum problem.

1. The Problem Statement

Given a 1-indexed array of integers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number.

  • Brute Force (O(N²)): A nested loop approach checking every possible pair—too slow for high-performance requirements.
  • HFT Optimized (O(N)): Since the array is already sorted, we can use a Two-Pointer approach to find the target in a single pass.

2. The Logic

  • Initialize Pointers: Place one pointer (left) at the beginning of the array and another (right) at the end.
  • Sum Comparison: If the current sum is greater than the target, decrement the right pointer to decrease the sum. If the sum is less than the target, increment the left pointer.
  • Memory Optimization: I initially used long long for the sum but realized a standard int was sufficient given the input constraints, avoiding unnecessary memory overhead.

3. Results

  • Time Complexity: O(N)
  • Space Complexity: O(1)
  • Index Adjustment: Because the problem uses 1-based indexing, I adjusted the final indices by adding 1 to the result pointers.

Current Status: 5/90 Days Complete

Today was a "reality check" day, but the 90-day grind doesn't stop for bad moods or failed OAs. I'll be back tomorrow to pick up the pace, likely moving toward Three Sum problems.

#HFT #CPP #TwoPointers #90DayChallenge #MAIT #TypeScript #Discipline