Maximize Interest From a Non-Overlapping CD Ladder

Last updated: November 29, 2026

Quick Overview

You are offered certificates of deposit, each locking funds from a start month to an end month for a known total interest. With a single pool of funds that can sit in only one CD at a time, choose CDs to maximize total interest and return the chosen set.

SoFi
Coding & Algorithms
Software Engineer
SoFi
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


You are offered certificates of deposit, each locking funds from a start month to an end month for a known total interest. With a single pool of funds that can sit in only one CD at a time, choose CDs to maximize total interest and return the chosen set.

SoFi offers savings and has explored CD style products; planning tools that recommend a sequence of locked terms map onto weighted interval scheduling. This hard onsite question checks that you reject greedy approaches, set up a DP over intervals sorted by end, use binary search for the compatible predecessor, and reconstruct the choice.

What the Interviewer Expects
  • Shows that greedy by highest interest or earliest end fails
  • Sorts by end month and defines dp over prefixes
  • Uses bisect to find the last CD ending at or before a start month
  • Reconstructs the chosen CDs, not just the total
  • Validates against brute force on small cases
Key Topics to Cover
dynamic programming
weighted interval scheduling
binary search
reconstruction
savings products
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
  • How would you handle two pools of money, so up to two CDs can overlap?
  • What if early withdrawal is allowed with a penalty?
  • How would the solution change if interest compounds across consecutive CDs?
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

Offers are (start, end, interest_cents) locking funds on [start, end), so a CD ending in month 12 can be followed by one starting in month 12. Maximize the sum of interest over a set of pairwise n...

High-Level Design

Greedy fails: taking the highest interest CD first can block two smaller ones that sum to more, and earliest-end-first ignores weights. Sort by end. Let dp[i] be the best total using the first i off...


Submit Your Answer
Markdown supported

Related Questions