#462 Implement a Limit Checking System

Companies:
Yandex
Themes:
System DesignPractice

You are a backend developer at a fintech company. The company provides payment services and must enforce user limits. A product owner asks you to create a system that checks limits before payments are processed.

Definitions

Payment:

  • Amount in rubles;
  • Operation type, debit only;
  • timestamp.

User limits:

  • Daily amount limit.
  • Maximum amount of a single operation;

Operation history:

  • A list of the user's completed payments.

Exercise

Implement a limit checking system that:

  • Accepts a payment and a user id;
  • Checks all configured limits;
  • Returns whether the operation may be performed;
  • If it cannot be performed, returns the reason and identifies which limit was exceeded.

Constraints

For this exercise, assume that all payments for the same user are processed strictly sequentially. No payment for that user can be processed while the limit check is running.

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in