FastPrepBest Currency Conversion Path
Problems/Best Currency Conversion Path

Best Currency Conversion Path

Squarepoint Capital logoSquarepoint Capital● HardNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The candidate reports finding the best conversion path from quoted currency rates and writing the solution with classes and OOP. This version keeps a path witness and adds directed rational quotes, no profitable cycles, ties and finite bounds. These details were not specified in the report, for about an 80% match.

There are n currencies numbered from zero. A directed quote [u,v,p,q] converts one unit of currency u into exactly p/q units of v. Return the currency-ID path from source to destination with the greatest product of conversion rates. A quote does not imply its reverse.

For this exercise, assume there are no profitable directed cycles. Among equally good conversion amounts, prefer fewer edges, then the lexicographically smallest ID sequence. Return [] when the destination is unreachable and [source] when the endpoints are equal. Compare rates exactly. The interview also asks for classes and object-oriented organization; the reference places quotes and path selection in an exchange-graph object. The automated judge checks the returned path.

Function

bestCurrencyPath(n: int, quotes: int[][], source: int, destination: int) → int[]

Examples

Example 1

n = 3quotes = [[0,1,9,5],[1,2,23,10],[0,2,4,1]]source = 0destination = 2return = [0,1,2]

The two-edge path yields (9/5)*(23/10) = 207/50 = 4.14, greater than the direct rate 4. Return the full path [0,1,2].

Example 2

n = 4quotes = [[0,2,2,1],[2,3,3,1],[0,1,3,1],[1,3,2,1]]source = 0destination = 3return = [0,1,3]

Both paths yield 6 in two edges. Compare their ID sequences: [0,1,3] is lexicographically smaller than [0,2,3].

Example 3

n = 2quotes = [[0,1,2,1]]source = 1destination = 0return = []

The only quote goes from 0 to 1. There is no reverse quote, so 0 is unreachable from 1.

Constraints

  • 1 <= n <= 12.
  • 0 <= quotes.length <= 132, and every quote has exactly 4 integers.
  • Every quote integer lies in 0..30.
  • 0 <= source <= 11 and 0 <= destination <= 11; both IDs are less than n.
  • Each quote is [from,to,numerator,denominator], with distinct endpoints in 0..n-1 and numerator and denominator in 1..30. Each ordered pair occurs at most once. No directed cycle has a product greater than one.

More Squarepoint Capital Phone Screen questions

  • Newton Square Root to a Guaranteed TolerancePHONE SCREEN · Seen Nov 2026
  • Probability of Consecutive HeadsPHONE SCREEN · Seen Nov 2026
  • Three Points in a Semicircle: Monte Carlo EstimatePHONE SCREEN · Seen Nov 2026
  • Combine Two Index SequencesPHONE SCREEN · Seen Aug 2026
  • Parse, Normalize, and Combine PolynomialsPHONE SCREEN · Seen Aug 2026
  • Sorted Insertion SnapshotsPHONE SCREEN · Seen Aug 2026
  • Strong and Weak Reference LifecyclePHONE SCREEN · Seen Aug 2026
  • Target Sum Across Two Sorted ArraysPHONE SCREEN · Seen Aug 2026
  • Classify Heap Addresses from a Memory SnapshotPHONE SCREEN · Seen Nov 2025
  • Fixed Worker Pool with a Shared QueuePHONE SCREEN · Seen Nov 2025

Similar questions at other companies

  • Process Graph Rule ValidationHadrian · PHONE SCREENHadrian interview questions
  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Employee Hierarchy Cycle and Depth AnalysisMicrosoft · PHONE SCREENMicrosoft interview questions
  • Minimum Leaf Path Sum over All RootsInfosys · OAInfosys interview questions
  • Sum of Weighted Distances in a TreeGoogle · ONSITE INTERVIEWGoogle interview questions
  • Longest Decreasing Matrix Path with Limited RelaxationsDuolingo · ONSITE INTERVIEWDuolingo interview questions
  • Tree Node With Maximum BeautyC3.ai · OAC3.ai interview questions
  • Rocket Component CostSpaceX · ONSITE INTERVIEWSpaceX interview questions
  • Maximum Reservoir PowerWells Fargo · OAWells Fargo interview questions
  • Distance Sums to Special Nodes in a Weighted TreeNutanix · ONSITE INTERVIEWNutanix interview questions

Interview reports that mention this question

  • Squarepoint Campus SDE Interviews: 7 Experiences (Part 2 of 2)

Squarepoint Capital interview experiences

  • Squarepoint Capital C++ and Python SWE Interviews: 7 Experiences
  • Squarepoint Capital New Grad SDE OA: 5 Experiences (Part 1 of 2)
All Squarepoint Capital interview questionsSee Squarepoint Capital hiring insights
Saved
class Solution {
    public int[] bestCurrencyPath(int n, int[][] quotes, int source, int destination) {
        // write your code here
    }
}
Checking account…