【leetcode】1154. Day of the Year 题目如下: Given a stringdaterepresenting aGregorian calendardate formatted asYYYY-MM-DD, return the day number of the year. Example 1: Input: date = "2019-01-09" Output: 9 Explanat
Runtime:20 ms, faster than99.51% of Python3 online submissions for Day of the Year. Memory Usage:13.8 MB, less than52.20% of Python3 online submissions for Day of the Year. 简洁一点的写法 classSolution:defdayOfYear(self, date: str) ->int: y, m, d= map(int, date.split('-')) ...
class Solution { public: int dayOfYear(string date) { int year = stoi(date.substr(0, 4)); int month = stoi(date.substr(5, 2)); int day = stoi(date.substr(8)); return countDays(day, month, year); } bool isLeapYear(int year) { return (year % 4 == 0 && year % 100 != ...
LeetCode-1185. Day of the Week Given a date, return the corresponding day of the week for that date. The input is given as three integers representing the day, month and year respectively. Return the answer...[leetcode] 1185. Day of the Week Description Given a date, return the ...
class Solution { public: string dayOfTheWeek(int day, int month, int year) { int totalDays = 4; vector<int>monthDays{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; vector<string>days{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}...
classSolution:deftwoSum(self,nums:List[int],target:int)->List[int]:hashmap={}foritinrange(len(nums)):num=nums[it]diff=target-numifhashmap.get(num,None)isnotNone:#hashmap contains the other half of this numberreturn[hashmap[num],it]else:# hashmap not contain what we want# save the...
=1900&&year%4==0&&month>2?++day:day;}} Python: importtimeclassSolution:defdayOfYear(self,date:str)->int:returntime.strptime(date,"%Y-%m-%d")[-2]
提示: date.length == 10 date[4] == date[7] == ‘-’,其它的 date 都是数字 代码语言:javascript 代码运行次数:0 运行 AI代码解释 classSolution{publicintdayOfYear(String date){int totalDays=0;int year=Integer.parseInt(date.substring(0,4));int month=Integer.parseInt(date.substring(5,7));...
//cdn.jsdelivr.net/gh/MUYIio/CDN@1.2/Images/logo.png" class="logo-img circle responsive-img"> <div class="logo-name">Shawlon`s Blog</div> <div class="logo-desc"> C++ | LeetCode | Algorithm </div> </div> <ul class="menu-list mobile-menu-list"> <li> <a href="/" ...
1.题目:Given a string s, partition s such that every substring of the partition is apalindrome.Return the minimum cuts needed for apalindromepartitioningof s. 2. 01背包问题c++实现 leetcode腾讯精选009 题目:https://leetcode-cn.com/problems/palindrome-number/ 代码: classSolution{ public: bool ...