Intuit – Software Engineer (Frontend) – Phone Screen

Description:
Level: SDE 2 (Frontend)**
Education: Bachelor’s
Years of Experience (YOE): 3
Questions Asked:
You were asked to implement a function that calculates the optimal change in:

  • Dollars
  • Quarters (25¢)
  • Dimes (10¢)
  • Pennies (1¢)

Given an amount in cents, the function should return the minimal number of each unit required.


Example 1:

Input:
87
(87 cents)

Output:

{
  dollars: 0,
  quarters: 3,
  dimes: 1,
  pennies: 2
}

Explanation:
3×25 = 75
1×10 = 10
2×1 = 2
Total = 87


Example 2:

Input:
237
($2.37)

Output:

{
  dollars: 2,
  quarters: 1,
  dimes: 1,
  pennies: 2
}

Explanation:
2×100 = 200
1×25 = 25
1×10 = 10
2×1 = 2
Total = 237