【Leetcode_easy】1154. Day of the Year
problem
solution
class Solution {
public:
int dayOfYear(string date) {
// 平年 闰年
int days[] = {, , , , , , , , , , , };
int y = stoi(date.substr(, )), m = stoi(date.substr(, )), d = stoi(date.substr());
if(m> && y % == && (y % != || y % == )) d++;//leap year..errr..
while(--m) d += days[m-];//errr..
return d;
}
};
参考
1. Leetcode_easy_1154. Day of the Year;
完
【Leetcode_easy】1154. Day of the Year的更多相关文章
- 【Leetcode_easy】1021. Remove Outermost Parentheses
problem 1021. Remove Outermost Parentheses 参考 1. Leetcode_easy_1021. Remove Outermost Parentheses; 完
- 【Leetcode_easy】1022. Sum of Root To Leaf Binary Numbers
problem 1022. Sum of Root To Leaf Binary Numbers 参考 1. Leetcode_easy_1022. Sum of Root To Leaf Binar ...
- 【Leetcode_easy】1025. Divisor Game
problem 1025. Divisor Game 参考 1. Leetcode_easy_1025. Divisor Game; 完
- 【Leetcode_easy】1029. Two City Scheduling
problem 1029. Two City Scheduling 参考 1. Leetcode_easy_1029. Two City Scheduling; 完
- 【Leetcode_easy】1030. Matrix Cells in Distance Order
problem 1030. Matrix Cells in Distance Order 参考 1. Leetcode_easy_1030. Matrix Cells in Distance Orde ...
- 【Leetcode_easy】1033. Moving Stones Until Consecutive
problem 1033. Moving Stones Until Consecutive 参考 1. Leetcode_easy_1033. Moving Stones Until Consecut ...
- 【Leetcode_easy】1037. Valid Boomerang
problem 1037. Valid Boomerang 参考 1. Leetcode_easy_1037. Valid Boomerang; 完
- 【Leetcode_easy】1042. Flower Planting With No Adjacent
problem 1042. Flower Planting With No Adjacent 参考 1. Leetcode_easy_1042. Flower Planting With No Adj ...
- 【Leetcode_easy】1046. Last Stone Weight
problem 1046. Last Stone Weight 参考 1. Leetcode_easy_1046. Last Stone Weight; 完
随机推荐
- Thinkphp远程代码执行 payload汇总
Thinkphp 5.0.22http://192.168.1.1/thinkphp/public/?s=.|think\config/get&name=database.usernameht ...
- C# 遍历 enum 枚举
foreach (Suit suit in (Suit[]) Enum.GetValues(typeof(Suit))) { } 注意:强制转换(Suit[])不是必需的,但确实使代码快0.5 ns.
- Oracle substr() 字符截取函数
1.substr函数格式 (俗称:字符截取函数) 格式1: substr(string string, int a, int b); 格式2:substr(string string, int a ...
- learning java AWT EventQs
import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.Ac ...
- QGraphicsView,QGraphicsScene,QGraphicsItem
参考:Qt4 开发实践第八章 图形视图QGraphicsView #ifndef DRIVEDGRAPH_H #define DRIVEDGRAPH_H #include <QObject> ...
- $\text{fhq-treap}$总结
\(\text{fhq-treap}\)总结 又名范浩强\(\text{treap}\),是一种无旋\(\text{treap}\).其原理同\(\text{treap}\)一样都是通过维护一个随机堆 ...
- Python3文件
open()方法 Python open()方法永于打开一个文件,并返回文件对象,并对文件进行处理过程中都需要用到这个方法,如果该文件无法被打开,则抛出OSError 注意:使用open()方法一定要 ...
- 9.本地线程(ThreadLoca)
ThreadLoca 提高一个线程的局部变量,访问某个线程都有自己的局部变量,当使用ThreadLoca为每个使用该变量的线程提供独立的变量副本,所以每一个线程都可以独立的改变自己的副本,二不会影响到 ...
- 数组不能用for each ,
数组不能用for each 不能用这 for(String xkz:xkzzj){ SjshdcDTO sjshdcDTO = cpcyService.findSjshdcDTOById(xkz); ...
- OpenFOAM-圆柱绕流
原版视频下载地址:https://yunpan.cn/c64yrdt9J5LmQ 访问密码 0128 首先进行建模操作,任何建模软件均可,本教程采用ICEM直接建模,模型尺寸如下: 建成的模型如下: ...