FastPrepIntegers With Multiple Sum of Two Cubes
Problems/Integers With Multiple Sum of Two Cubes

Integers With Multiple Sum of Two Cubes

Charta Health logoCharta Health● MediumFULLTIMENEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: In the Charta Health on-site for a Senior Software Engineer role, the first interview was a coding round on the well-known problem Integers With Multiple Sum of Two Cubes, named only by a link. The interviewer then asked how to handle a larger required number of pairs, d, and sums of c cubes instead of two.

The report gives no limits or examples. This version uses the usual rules. The numbers a and b are positive with a <= b, and a good number needs at least two different pairs. The number n is at most 10^9, and the answer is sorted from smallest to largest. Both follow-ups are discussed in the editorial, and tests do not check them.

Our version is about 85% the same as the reported question.

Special thanks: 🌷 A special thank you to a lovely, amazing fren who shared that this question also appeared on November 11, 2026! ٩(ˊᗜˋ*)و ♡ 🩵

Call an integer x good when it can be written as a^3 + b^3, with positive integers a <= b, in at least two different ways. Two ways are different when their pairs (a, b) are different.

For example, 1729 is good, because 1729 = 1^3 + 12^3 and also 1729 = 9^3 + 10^3.

Given an integer n, return every good integer x with x <= n, sorted from smallest to largest. Each good integer appears once. If there is none, return an empty list.

Function

findGoodIntegers(n: int) → List<Integer>

Examples

Example 1

n = 4104return = [1729,4104]

1729 = 1^3 + 12^3 = 9^3 + 10^3 and 4104 = 2^3 + 16^3 = 9^3 + 15^3. No other integer up to 4104 has two different pairs.

Example 2

n = 1728return = []

1729 is the smallest good integer, so nothing up to 1728 is good.

Example 3

n = 20000return = [1729,4104,13832]

The next good integer after 4104 is 13832 = 2^3 + 24^3 = 18^3 + 20^3. The one after that is 20683, which is larger than 20000.

Constraints

  • 1 <= n <= 10^9

More Charta Health interview questions

  • Inorder Successor in a Binary Search TreeONSITE INTERVIEW · Seen Sep 2026
  • Design Hit CounterPHONE SCREEN · Seen Nov 2026
  • Insert Delete GetRandom O(1)PHONE SCREEN · Seen Nov 2026
  • Concurrent Token-Bucket Rate LimiterPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Top K Frequent WordsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Financial Account LedgerStripe · OA · PHONE SCREENStripe interview questions
  • Retrieve Vectors by Cosine SimilarityHarvey · ONSITE INTERVIEWHarvey interview questions
  • Match Orders by Price and Arrival TimeAkuna Capital · OA · PHONE SCREEN · ONSITE INTERVIEWAkuna Capital interview questions
  • Worst-Performing Ads by CTR in a Campaign TreeUber · PHONE SCREENUber interview questions
  • Design Authentication ManagerOracle · ONSITE INTERVIEWOracle interview questions
  • In-Memory Priority Task SchedulerRippling · PHONE SCREENRippling interview questions
  • Balanced Session ManagerPalantir · PHONE SCREENPalantir interview questions
  • Design a Food Rating SystemApple · PHONE SCREENApple interview questions
  • Key-Value Store on a Block DeviceLambda · PHONE SCREEN
All Charta Health interview questionsSee Charta Health hiring insights
Saved
class Solution {
    public List<Integer> findGoodIntegers(int n) {
        // Write your code here.
    }
}
Checking account…