FastPrepCan Three Numbers Form a Valid Date?
Problems/Can Three Numbers Form a Valid Date?

Can Three Numbers Form a Valid Date?

Google logoGoogle● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks whether any ordering of three given integers makes a valid date. We fixed the Gregorian rules and the range of years. Our version is about 82% the same as the reported question.

Given three positive integers, decide whether some permutation can represent a valid Gregorian date [year,month,day].

The year must be in [1,9999]. Apply ordinary Gregorian leap-year rules: divisible by 400, or divisible by 4 but not 100. Each input number is used exactly once.

Function

canFormValidDate(values: int[]) → boolean

Examples

Example 1

values = [2024,2,29]return = true

2024 is a leap year, so February 29 is valid.

Example 2

values = [31,4,2024]return = false

No permutation forms a valid date because April has only 30 days and the other placements fail month/year bounds.

Example 3

values = [12,25,2025]return = true

The permutation [2025,12,25] is valid.

Constraints

  • values.length = 3.
  • 1 <= values[i] <= 9999.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
  • Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
  • Exponential Backoff DelaysWonderful · PHONE SCREEN
  • Recover Document Hierarchy from IndentationReducto · PHONE SCREEN
  • Latency Bucket CounterDatadog · OA · PHONE SCREENDatadog interview questions
  • Mini-Batch Data LoaderOpenAI · PHONE SCREENOpenAI interview questions
  • Sliding Window Attention over a KV CacheNVIDIA · PHONE SCREENNVIDIA interview questions
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Deterministic K-Means AssignmentsLyft · PHONE SCREENLyft interview questions
  • Deterministic K-Means AssignmentsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public boolean canFormValidDate(int[] values) {
        // Write your code here.
    }
}
Checking account…