Skip to content

Practice Convert Date to Binary

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3280
LeetCode Problem

Convert Date to Binary

Problem Statement

You are given a string date representing a Gregorian calendar date in the yyyy-mm-dd format. date can be written in its binary representation obtained by converting year, month, and day to their binary representations without any leading zeroes and writing them down in year-month-day format. Return the binary representation of date.

Source: Convert Date to Binary on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
date = "2080-02-29"
Output
"100000100000-10-11101"

# Example 2

Input
date = "1900-01-01"
Output
"11101101100-1-1"

Constraints

date.length == 10
date[4] == date[7] == '-', and all other date[i]'s are digits.
The input is generated such that date represents a valid Gregorian calendar date between Jan 1st, 1900 and Dec 31st, 2100 (both inclusive).

Related LeetCode Problems

Practice more problems similar to Convert Date to Binary.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.