diff --git a/README.md b/README.md index 7f7be89..e01a6c6 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ The listing below is sorted based on LeetCode #. If you are interested to see my | 1145 | [Binary Tree Coloring Game](/problems/binary-tree-coloring-game/) | Medium | Tree, depth-first search | | 1150 | [Check If a Number Is Majority Element in a Sorted Array](/problems/is-a-a-majority-element) | Easy | Array, binary search | | 1153 | [String Transforms Into Another String](/problems/string-transforms-into-another-string) | Hard | Graph | -| 1154 | [Day of the Year](/problems/ordinal-number-of-date) | Easy | Math | +| 1154 | [Day of the Year](problems/day-of-the-year) | Easy | Math | | 1160 | [Find Words That Can Be Formed by Characters](/problems/find-words-that-can-be-formed-by-characters) | Easy | Array, hash table | | 1161 | [Maximum Level Sum of a Binary Tree](/problems/maximum-level-sum-of-a-binary-tree) | Medium | Graph | | 1162 | [As Far from Land as Possible](/problems/as-far-from-land-as-possible) | Medium | Breadth-first search, graph | diff --git a/package-lock.json b/package-lock.json index 0549bea..b4bb764 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "leetcode", - "version": "1.28.0", + "version": "1.28.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -631,9 +631,9 @@ } }, "@tootallnate/once": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.0.0.tgz", - "integrity": "sha512-KYyTT/T6ALPkIRd2Ge080X/BsXvy9O0hcWTtMWkPvwAwF99+vn6Dv4GzrFT/Nn1LePr+FFDbRXXlqmsy9lw2zA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", + "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "dev": true }, "@types/babel__generator": { @@ -818,9 +818,9 @@ "dev": true }, "agent-base": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.0.tgz", - "integrity": "sha512-j1Q7cSCqN+AwrmDd+pzgqc0/NpC655x2bUf5ZjRIO77DcNBFmh+OgRNzF6OKdCC9RSCb19fGd99+bhXFdkRNqw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.1.tgz", + "integrity": "sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg==", "dev": true, "requires": { "debug": "4" @@ -1282,9 +1282,9 @@ "dev": true }, "codecov": { - "version": "3.6.5", - "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.6.5.tgz", - "integrity": "sha512-v48WuDMUug6JXwmmfsMzhCHRnhUf8O3duqXvltaYJKrO1OekZWpB/eH6iIoaxMl8Qli0+u3OxptdsBOYiD7VAQ==", + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.7.2.tgz", + "integrity": "sha512-fmCjAkTese29DUX3GMIi4EaKGflHa4K51EoMc29g8fBHawdk/+KEq5CWOeXLdd9+AT7o1wO4DIpp/Z1KCqCz1g==", "dev": true, "requires": { "argv": "0.0.2", diff --git a/package.json b/package.json index c8e5646..5902ea4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "leetcode", - "version": "1.28.0", + "version": "1.28.1", "description": "My solutions for LeetCode problems.", "main": "index.js", "scripts": { @@ -22,7 +22,7 @@ }, "homepage": "https://github.com/ecgan/leetcode", "devDependencies": { - "codecov": "^3.6.5", + "codecov": "^3.7.2", "eslint": "^6.8.0", "eslint-config-standard": "^14.1.0", "eslint-plugin-import": "^2.20.1", diff --git a/problems/day-of-the-year/README.md b/problems/day-of-the-year/README.md new file mode 100644 index 0000000..3472a5a --- /dev/null +++ b/problems/day-of-the-year/README.md @@ -0,0 +1,46 @@ +# Day of the Year + +LeetCode #: [1154](https://leetcode.com/problems/day-of-the-year/) + +Difficulty: Easy + +Topics: Math. + +## Problem + +Given a string `date` representing a [Gregorian calendar](https://en.wikipedia.org/wiki/Gregorian_calendar) date formatted as `YYYY-MM-DD`, return the day number of the year. + +Example 1: + +```text +Input: date = "2019-01-09" +Output: 9 +Explanation: Given date is the 9th day of the year in 2019. +``` + +Example 2: + +```text +Input: date = "2019-02-10" +Output: 41 +``` + +Example 3: + +```text +Input: date = "2003-03-01" +Output: 60 +``` + +Example 4: + +```text +Input: date = "2004-03-01" +Output: 61 +``` + +Constraints: + +- `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. diff --git a/problems/ordinal-number-of-date/solution.js b/problems/day-of-the-year/dayOfYear.js similarity index 100% rename from problems/ordinal-number-of-date/solution.js rename to problems/day-of-the-year/dayOfYear.js diff --git a/problems/ordinal-number-of-date/solution.test.js b/problems/day-of-the-year/dayOfYear.test.js similarity index 95% rename from problems/ordinal-number-of-date/solution.test.js rename to problems/day-of-the-year/dayOfYear.test.js index 9f5edcf..216a6ae 100644 --- a/problems/ordinal-number-of-date/solution.test.js +++ b/problems/day-of-the-year/dayOfYear.test.js @@ -1,4 +1,4 @@ -const dayOfYear = require('./solution') +const dayOfYear = require('./dayOfYear') test('Example 1', () => { const date = '2019-01-09' diff --git a/problems/ordinal-number-of-date/README.md b/problems/ordinal-number-of-date/README.md deleted file mode 100644 index 13dfebf..0000000 --- a/problems/ordinal-number-of-date/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Day of the Year - -[Link to LeetCode page](https://leetcode.com/problems/ordinal-number-of-date/) - -Difficulty: Easy - -Topics: -