[LeetCode]#1154. Day of the Year

Input: date = "2019-01-09"
Output: 9
Explanation: Given date is the 9th day of the year in 2019.
Input: date = "2019-02-10"
Output: 41
Input: date = "2003-03-01"
Output: 60
Input: date = "2004-03-01"
Output: 61
  • date.length == 10
  • date[4] == date[7] == '-', and all other date[i]'s are digits
  • date represents a calendar date between Jan 1st, 1900 and Dec 31, 2019.
import datetime
class Solution:
def dayOfYear(self, date):
if year_check % 400 ==0:
if year_check % 4 ==0 and year_check % 100 !=0:
day1 = datetime.datetime(int(date[0:4]), int(date[5:7]) , int(date[8:10]))
day2 = datetime.datetime(int(date[0:4]), int(12) , int(31))
return ans

Interesting in any computer science.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to make Database Models in Django

Service and Maintenance Management — AssetSonar

Tutorial Fuzzy Logic Mamdani for Arduino

Tutorial Fuzzy Logic Mamdani for Arduino

Hacking For Beginners

Generating and Solving Mazes with Python

Learning C++: Sorted-Range Algorithms of the STL Part 2

sTokens, Social Tokens and Unlock Protocol — Creators Portal

Fixing React Native build error: Undefined symbols for architecture x86_64

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fatboy Slim

Fatboy Slim

Interesting in any computer science.

More from Medium

Analytical skills matter in coding !

How is the current market for Data Scientist today?

Hackerrank — Merge Sorted Linked list walkthrough #Python #Hackerrank

10 Free Platforms to Brush Up your Coding Skills Before Interviews