Cluster Symbols Linked by Strong Return Correlation

Last updated: November 29, 2026

Quick Overview

Given a list of ticker symbols and pairwise return correlations, group symbols into clusters where two symbols are in the same cluster if they are connected by a chain of pairs whose absolute correlation is at or above a threshold.

SIG
Coding & Algorithms
Software Engineer
SIG
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given a list of ticker symbols and pairwise return correlations, group symbols into clusters where two symbols are in the same cluster if they are connected by a chain of pairs whose absolute correlation is at or above a threshold.

SIG hedges and nets risk across related products such as an ETF and its largest components, and grouping instruments by correlation is a realistic step in that work. The interviewer is testing union-find with path compression and union by size, plus thinking about what threshold-linkage clustering means.

What the Interviewer Expects
  • Recognize transitive grouping as connected components
  • Implement union-find with path compression and union by size
  • Include symbols that have no qualifying pairs as singletons
  • Use absolute correlation so strong negative links also cluster
  • Return groups in a deterministic order
Key Topics to Cover
union find
connected components
clustering
path compression
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Why might single-linkage chaining produce a misleading giant cluster?
  • How would you answer queries for many thresholds efficiently?
  • How would you maintain clusters as new correlation estimates arrive daily?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: symbols, pairs as (a, b, rho), and threshold. Two symbols join a cluster if abs(rho) >= threshold, and joining is transitive. Output: list of clusters, each sorted, ordered largest fi...

High-Level Design

This is connected components in the graph of strong edges. BFS over an adjacency list works, but union-find is simpler when edges arrive as a list, and it supports adding edges incrementally. Path com...


Submit Your Answer
Markdown supported