FastPrepFor All Intents And Purposes Part 2 - Change Is Good! πŸ‘
Problems/For All Intents And Purposes Part 2 - Change Is Good! πŸ‘

For All Intents And Purposes Part 2 - Change Is Good! πŸ‘

Stripe logoStripe● EasyINTERNNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

🐝 Hi there! The description you are currently reading is just 2nd part of the problem set. It is highly recommended to read ALL THE PARTS before coding as parts may build on top of each other 🐳

  • For All Intents And Purposes Part 1 - Initilizing the System πŸ—οΈ
  • For All Intents And Purposes Part 2 - Change Is Good! πŸ‘
  • For All Intents And Purposes Part 3 - Accepting Failure 😌
  • For All Intents And Purposes Part 4 - Timing Matters ⏰

The initial version of our system looks good πŸ˜„πŸ‘! But it turns out merchants also need to be able to update the amount of initialized Payment Intents. This happen if a customer begins to check out but then decides to change the items in their shopping cart πŸ›’ and thus the amount of the payment. Let's add that the our system 🍻!

All commands from Part 1 (INIT, CREATE, ATTEMPT and SUCCEED) still work exactly as described there. The output is also the same as in Part 1: one string "<merchant_id> <balance>" for every initialized merchant, sorted by merchant ID. IDs are compared as plain strings, character by character (so m10 comes before m2).

Commands

Your system should support an additional command for updaing a Payment Intent.

UPDATE <payment_intent_id> <new amount>

  • Update the monetary amount of an existing Payment Intent in the REQUIRES_ACTION state. This does not transition the state of the Payment Intent.
  • If no Payment Intent with the given identifier exists, or if the Payment Intent is not in the REQUIRES_ACTION state, or if the new amount is negative, this mommand should do nothing.

Function

forAllIntentsAndPurposes2(commands: String[]) β†’ String[]

Examples

Example 1

commands = ["INIT m1 0", "CREATE p1 m1 50", "UPDATE p1 100",  "ATTEMPT p1", "SUCCEED p1"]return = ["m1 100"]

While the Payment Intent p1 was initially created with an amount of 50, this was then updated to 100 before being attempted then succeeded. Therefore, merchant m1 has a balance of 100 after all commands have been processed.

Constraints

  • 1 ≀ commands.length ≀ 10^4
  • Each command is one of INIT, CREATE, ATTEMPT, SUCCEED or UPDATE, written exactly as described, with single spaces between its parts.
  • Merchant IDs and Payment Intent IDs have 1 to 10 characters, and every character is a lowercase English letter or a digit.
  • 0 ≀ starting_balance ≀ 10^5
  • -10^5 ≀ amount, new amount ≀ 10^5
  • Every number is a plain decimal integer (a minus sign only for negative numbers, no leading zeros).

More Stripe interview questions

  • Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN Β· Seen Nov 2026
  • Financial Account LedgerOA Β· PHONE SCREEN Β· Seen Nov 2026
  • Business Account KYC Verification β€” Parts 1–5PHONE SCREEN Β· Seen Nov 2026
  • Chat Billing CalculationOA Β· Seen Nov 2026
  • Render a Task Tree from CSV RowsPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
  • Deployment Window SchedulerOA Β· Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
  • Linked Merchants Within Two HopsPHONE SCREEN Β· Seen Nov 2026
  • Asynchronous Event ProcessingOA Β· Seen Nov 2026
  • Portfolio Valuation, Part 1PHONE SCREEN Β· Seen Nov 2026

Similar questions at other companies

  • Student and Course EnrollmentWells Fargo Β· OAWells Fargo interview questions
  • Overheat Prevention ControllerOptiver Β· OAOptiver interview questions
  • LFU CacheSnowflake Β· OA Β· ONSITE INTERVIEWSnowflake interview questions
  • Corporate Card Expense RulesRippling Β· OA Β· PHONE SCREEN Β· ONSITE INTERVIEWRippling interview questions
  • Least Recently Used CacheMicrosoft Β· OA Β· PHONE SCREEN Β· ONSITE INTERVIEWMicrosoft interview questions
  • Parcel Attribute Store with TTLAirbnb Β· OAAirbnb interview questions
  • Process Banking OperationsVercel Β· OA
  • Four-Level Banking System with Scheduled PaymentsZipRecruiter Β· OAZipRecruiter interview questions
  • Expiring Authentication Token ManagerIBM Β· OAIBM interview questions
  • LFU CacheArista Networks Β· OAArista Networks interview questions

Interview reports that mention this question

  • Stripe SWE Intern Payment Intent OA: 1 Experience

Stripe interview experiences

  • Stripe SWE Onsite over Two Days: 1 Experience
  • Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences
  • Stripe AI Coding Interview, Experienced SWE: 6 Experiences
  • Stripe SWE Intern Payout Scheduler Phone Screen: 1 Experience
  • Stripe New Grad SWE Onsite and HM Round: 1 Experience
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] forAllIntentsAndPurposes2(String[] commands) {
      // write your code here
    }

}
Checking account…