FastPrepMonthly Calendar with Custom Week Start
Problems/Monthly Calendar with Custom Week Start

Monthly Calendar with Custom Week Start

Stripe logoStripe● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Stripe intern phone screen. The report leaves out the weekday pseudocode that was given and the exact calendar rules and formatting. Our version is about 90% the same as the reported question.

You are given a year, a month, and a weekday startDay. Return that month's calendar as a matrix of integers.

Calendar conventions

  • For this exercise, use the Gregorian calendar rules for every supported year, including years before 1582.
  • A year is a leap year if it is divisible by 400, or if it is divisible by 4 and not divisible by 100. February has 29 days in a leap year and 28 otherwise. April, June, September, and November have 30 days; the other months have 31.
  • For this exercise, number weekdays as 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, and 6 = Saturday.
  • The inputs are valid. You may compute weekdays using any correct method.

Calendar layout

  • Each row represents one week and contains exactly 7 cells.
  • The leftmost column is startDay. Each following column advances one weekday, wrapping from Saturday to Sunday.
  • Place the day numbers from 1 through the last day of the month in chronological order, under their corresponding weekdays.
  • For this exercise, fill cells before day 1 and after the month's last day with 0.
  • Return only weeks containing at least one day of the requested month. Do not add an all-zero row.

How the task builds up

The exercise builds the calendar in these steps:

  1. Find the weekday of a date.
  2. Use the month's length to find the weekday of its last day.
  3. Build a month table with weekday 0 in the first column.
  4. Let the first column be any startDay.

Write the final version, where the first column is startDay. You can use the earlier steps as helper functions.

Function

buildMonthlyCalendar(year: int, month: int, startDay: int) → int[][]

Examples

Example 1

year = 2024month = 2startDay = 1return = [[0,0,0,1,2,3,4],[5,6,7,8,9,10,11],[12,13,14,15,16,17,18],[19,20,21,22,23,24,25],[26,27,28,29,0,0,0]]

February 2024 starts on Thursday and has 29 days. The columns are Monday through Sunday, so the first row begins with three zeros. The last row contains 26, 27, 28, 29 followed by three zeros.

Example 2

year = 2021month = 2startDay = 1return = [[1,2,3,4,5,6,7],[8,9,10,11,12,13,14],[15,16,17,18,19,20,21],[22,23,24,25,26,27,28]]

February 2021 starts on Monday and has 28 days. With Monday as the first column, the month fills exactly four weeks and needs no padding.

Example 3

year = 2026month = 8startDay = 0return = [[0,0,0,0,0,0,1],[2,3,4,5,6,7,8],[9,10,11,12,13,14,15],[16,17,18,19,20,21,22],[23,24,25,26,27,28,29],[30,31,0,0,0,0,0]]

August 2026 starts on Saturday. The first row has six zeros before 1. The final row begins with Sunday 30 and Monday 31, so six rows are required.

Constraints

  • For this exercise, assume 1 <= year <= 9999.
  • 1 <= month <= 12.
  • 0 <= startDay <= 6.

More Stripe Phone Screen questions

  • Split Tender Part 4 - RefundsOA · PHONE SCREEN · Seen Nov 2026
  • Merchant Payout Reserve CalculatorPHONE SCREEN · Seen Nov 2026
  • Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
  • Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
  • Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE 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

Similar questions at other companies

  • Sliding Window Attention over a KV CacheNVIDIA · PHONE SCREENNVIDIA interview questions
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Fractional Share Inventory FlatteningRobinhood · PHONE SCREEN · ONSITE INTERVIEWRobinhood interview questions
  • Logistic Regression DiagnosticsLinkedIn · PHONE SCREENLinkedIn interview questions
  • Evenly Schedule Vehicle InspectionsAmazon · PHONE SCREEN
  • Implement Cross-Entropy LossOpenAI · PHONE SCREENOpenAI interview questions
  • Cumulative No-Intercept Regression BetasCitadel · PHONE SCREENCitadel interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
  • Automation Pipeline, Part 2: Stage WorkersPlaid · PHONE SCREENPlaid interview questions

Stripe interview experiences

  • Stripe New Grad SWE OA and Phone Screen: 2 Experiences
  • Stripe Experienced SWE OA and Onsite Questions: 3 Experiences
  • Stripe SWE Intern Linked Merchants Team Screen: 1 Experience
  • Stripe OA: What It Tests (2026)
  • Stripe SWE Onsite over Two Days: 1 Experience
  • Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public int[][] buildMonthlyCalendar(int year, int month, int startDay) {
        // write your code here
    }
}
Checking account…