FastPrepCalculate Server Shutdown Penalty
Problems/Calculate Server Shutdown Penalty

Calculate Server Shutdown Penalty

Stripe logoStripe● EasyNEW GRADINTERNPHONE SCREENONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reports describe penalty scoring at a given time. This practice uses binary server states; a later customer-hours diagram applies the same prefix/suffix rule with Y/N labels. The scored calculation matches the sources at about 95%.

A server log contains one state per time slot. The states are separated by whitespace:

  • 0 means the server was up and functioning during that slot.
  • 1 means the server was down during that slot.

You remove the server immediately before slot removedTime. Slots with indexes smaller than removedTime occur while the server is still installed; later slots occur after removal.

The penalty is the number of down slots before removal plus the number of up slots at or after removal. Return that total penalty.

Function

calculateShutdownPenalty(logs: String, removedTime: int) → int

Examples

Example 1

logs = "0 0 0 1 0 0"removedTime = 3return = 2

No down slot occurs before removal. Two up slots occur after it, so the penalty is 2.

Example 2

logs = "1 1 0 0"removedTime = 2return = 4

The two down slots before removal and the two up slots after removal each contribute one penalty point.

Example 3

logs = "0 1 1"removedTime = 0return = 1

The server is removed before every slot. Only the first slot was an up slot, so only it is penalized.

Constraints

  • 1 <= n <= 200000, where n is the number of log states.
  • Every state is exactly 0 or 1, separated by one or more whitespace characters.
  • 0 <= removedTime <= n.

More Stripe Phone Screen questions

  • Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
  • Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesPHONE SCREEN · Seen Nov 2026
  • Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
  • Portfolio Valuation, Part 1PHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Wallet Balance on a Selected DayBharatPe · PHONE SCREEN
  • Instrument Stack Language JumpsJane Street · PHONE SCREENJane Street interview questions
  • Schedule Buffered Video PlaybackNuro · PHONE SCREENNuro interview questions
  • Weighted Lottery WinnersAmazon · ONSITE INTERVIEW
  • Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
  • Array Challenge (QR Intern)Akuna Capital · OAAkuna Capital interview questions
  • Range Negation UpdatesJP Morgan Chase · OAJP Morgan Chase interview questions
  • Data UpdatesExpedia · OAExpedia interview questions
  • Hall of Shifting TilesAdobe · OAAdobe interview questions
  • Prefix Scores With the Running MaximumC3.ai · OAC3.ai interview questions

Interview reports that mention this question

  • Stripe SWE Intern Technical Screen Questions Guide
  • Stripe SWE Intern Bank OA and Closing Hours: 1 Experience
  • Stripe MLE Intern Server-Log Screen: 1 Experience
  • Stripe Seattle SWE Intern Logs, Limiter, Bikemap: 1 Experience
  • Stripe SWE Intern Closing-Penalty Screen: 1 Experience
  • Stripe MLE Intern Capital and Shutdown Rounds: 1 Experience
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public int calculateShutdownPenalty(String logs, int removedTime) {
      // write your code here
    }
}
Checking account…