Highest Point Back Rate a Campaign Budget Can Afford

Last updated: November 29, 2026

Quick Overview

Each purchase earns floor(amount * rate / 10000) points capped at a per-purchase limit, where rate is in basis points. Given purchases and a total points budget, find the largest integer rate whose total payout stays within budget.

Rakuten
Coding & Algorithms
Software Engineer
Rakuten
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Each purchase earns floor(amount * rate / 10000) points capped at a per-purchase limit, where rate is in basis points. Given purchases and a total points budget, find the largest integer rate whose total payout stays within budget.

Rakuten's point campaigns advertise back rates like 5x or 10x with per-order caps, and finance has to set the rate so expected payout fits a budget. The interviewer is checking whether you notice payout is monotonic in rate and binary search on the answer instead of simulating every rate.

What the Interviewer Expects
  • Prove payout is non-decreasing in rate
  • Binary search over the rate, not over purchases
  • Use integer math to avoid float rounding bugs
  • Pick the upper-mid variant to avoid infinite loops
  • Give O(n log R) complexity
Key Topics to Cover
binary search on answer
monotonic functions
integer arithmetic
budget constraints
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
  • Rates can be any real number. How do you search and when do you stop?
  • Make each payout evaluation faster than O(n) using sorting and prefix sums.
  • The cap now applies per user per month, not per purchase. What changes?
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

Purchases are (amount_yen, cap_points). Payout at rate r is sum(min(cap, amount * r // 10000)). Find the max r in [0, max_rate] with payout at most the budget. Rate 0 always pays 0, so an answer...

High-Level Design

Each term min(cap, floor(amount * r / 10000)) is non-decreasing in r, so the sum is too. That means the feasible rates form a prefix [0, r*], which is exactly the shape binary search on the answer...


Submit Your Answer
Markdown supported

Related Questions