From 0ac33de7bb4a7ed5efee244b83fd1f2aa11ce1b8 Mon Sep 17 00:00:00 2001 From: Dennis Bauer Date: Mon, 13 Apr 2026 22:17:28 +0200 Subject: [PATCH 1/3] Setup Problem + Fix missing things from last problem --- Problems/Daily Temperatures/README.md | 23 +++++++++++++++++++ .../daily temperatures.test.ts | 16 +++++++++++++ Problems/Daily Temperatures/solver.ts | 3 +++ Problems/Vertical-List/README.md | 2 +- Problems/Vertical-List/vertical-list.test.ts | 2 +- 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 Problems/Daily Temperatures/README.md create mode 100644 Problems/Daily Temperatures/daily temperatures.test.ts create mode 100644 Problems/Daily Temperatures/solver.ts diff --git a/Problems/Daily Temperatures/README.md b/Problems/Daily Temperatures/README.md new file mode 100644 index 0000000..b1324f1 --- /dev/null +++ b/Problems/Daily Temperatures/README.md @@ -0,0 +1,23 @@ +# Daily Temperatures + +You are given an array of integers temperatures where temperatures[i] represents the daily temperatures on the ith day. +Return an array where output[i] is the number of days after the ith day before a warmer temperature appears on a future day. If there is no day in the future where a warmer temperature will appear for the ith day, set output[i] to 0 instead. + +## Documentation + +### Solution Idea + +The Idea to solve this problem + +--- + +### [Implementation](./solver.ts) + +The implementation for solving this problem + +--- + +### Information's + +This problem comes from the newsletter [Sloth Bytes](https://slothbytes.beehiiv.com). +[Post](https://slothbytes.beehiiv.com/p/docker-for-dummies) from March 25, 2026. diff --git a/Problems/Daily Temperatures/daily temperatures.test.ts b/Problems/Daily Temperatures/daily temperatures.test.ts new file mode 100644 index 0000000..5dcedac --- /dev/null +++ b/Problems/Daily Temperatures/daily temperatures.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from "vitest"; +import dailyTemperatures from "./solver"; + +describe("Should return the correct days it takes to the next warm day", () => { + it("should return [1, 4, 1, 2, 1, 0, 0] for the first input", () => { + expect(dailyTemperatures([30, 38, 30, 36, 35, 40, 28])).toEqual([1, 4, 1, 2, 1, 0, 0]); + }); + + it("should return [0,0,0] for the second input", () => { + expect(dailyTemperatures([22, 21, 20])).toEqual([0, 0, 0]); + }); + + it("should return [1, 4, 1, 2, 1, 0, 0] for the first input", () => { + expect(dailyTemperatures([30, 38, 30, 37, 35, 40, 28])).toEqual([1, 4, 1, 2, 1, 0, 0]); + }); +}); diff --git a/Problems/Daily Temperatures/solver.ts b/Problems/Daily Temperatures/solver.ts new file mode 100644 index 0000000..1b7a05f --- /dev/null +++ b/Problems/Daily Temperatures/solver.ts @@ -0,0 +1,3 @@ +export default function dailyTemperatures(temps: number[]): number[] { + throw new Error("Solution yet not implemented!"); +} diff --git a/Problems/Vertical-List/README.md b/Problems/Vertical-List/README.md index 3171a17..87d8c76 100644 --- a/Problems/Vertical-List/README.md +++ b/Problems/Vertical-List/README.md @@ -27,4 +27,4 @@ By doing this for every word and every character, the solution array is built co ### Information's This problem comes from the newsletter [Sloth Bytes](https://slothbytes.beehiiv.com). -[Post](https://slothbytes.beehiiv.com/p/why-your-delete-button-is-a-lie) from May 18, 2026. +[Post](https://slothbytes.beehiiv.com/p/why-your-delete-button-is-a-lie) from March 18, 2026. diff --git a/Problems/Vertical-List/vertical-list.test.ts b/Problems/Vertical-List/vertical-list.test.ts index 755d2bf..369c3bb 100644 --- a/Problems/Vertical-List/vertical-list.test.ts +++ b/Problems/Vertical-List/vertical-list.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; import verticalTxt from "./solver"; -describe("Description for the tests", () => { +describe("Returns the same Text written from up to down", () => { it("should return a 2x7 Matrix for 'Holy bananas'", () => { expect(verticalTxt("Holy bananas")).toEqual([ ["H", "b"], From c36bb0eccddccf47ae6fde850c54da64560a0c8e Mon Sep 17 00:00:00 2001 From: Dennis Bauer Date: Mon, 13 Apr 2026 22:24:13 +0200 Subject: [PATCH 2/3] Solved the problem --- Problems/Daily Temperatures/solver.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Problems/Daily Temperatures/solver.ts b/Problems/Daily Temperatures/solver.ts index 1b7a05f..5353ea2 100644 --- a/Problems/Daily Temperatures/solver.ts +++ b/Problems/Daily Temperatures/solver.ts @@ -1,3 +1,7 @@ export default function dailyTemperatures(temps: number[]): number[] { - throw new Error("Solution yet not implemented!"); + return temps.map((temp, i) => { + for (let index = i + 1; index < temps.length; index++) if (temp < temps[index]) return index - i; + + return 0; + }); } From e65c2498558a5472a30bd98b1eda79fc68bf032f Mon Sep 17 00:00:00 2001 From: Dennis Bauer Date: Mon, 13 Apr 2026 22:29:36 +0200 Subject: [PATCH 3/3] Finished problem --- Problems/Daily Temperatures/README.md | 23 -------------- Problems/Daily-Temperatures/README.md | 30 +++++++++++++++++++ .../daily temperatures.test.ts | 0 .../solver.ts | 0 Problems/Vertical-List/README.md | 2 ++ README.md | 5 ++-- 6 files changed, 35 insertions(+), 25 deletions(-) delete mode 100644 Problems/Daily Temperatures/README.md create mode 100644 Problems/Daily-Temperatures/README.md rename Problems/{Daily Temperatures => Daily-Temperatures}/daily temperatures.test.ts (100%) rename Problems/{Daily Temperatures => Daily-Temperatures}/solver.ts (100%) diff --git a/Problems/Daily Temperatures/README.md b/Problems/Daily Temperatures/README.md deleted file mode 100644 index b1324f1..0000000 --- a/Problems/Daily Temperatures/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Daily Temperatures - -You are given an array of integers temperatures where temperatures[i] represents the daily temperatures on the ith day. -Return an array where output[i] is the number of days after the ith day before a warmer temperature appears on a future day. If there is no day in the future where a warmer temperature will appear for the ith day, set output[i] to 0 instead. - -## Documentation - -### Solution Idea - -The Idea to solve this problem - ---- - -### [Implementation](./solver.ts) - -The implementation for solving this problem - ---- - -### Information's - -This problem comes from the newsletter [Sloth Bytes](https://slothbytes.beehiiv.com). -[Post](https://slothbytes.beehiiv.com/p/docker-for-dummies) from March 25, 2026. diff --git a/Problems/Daily-Temperatures/README.md b/Problems/Daily-Temperatures/README.md new file mode 100644 index 0000000..2e602a9 --- /dev/null +++ b/Problems/Daily-Temperatures/README.md @@ -0,0 +1,30 @@ +# Daily Temperatures + +You are given an array of integers temperatures where temperatures[i] represents the daily temperatures on the ith day. +Return an array where output[i] is the number of days after the ith day before a warmer temperature appears on a future day. If there is no day in the future where a warmer temperature will appear for the ith day, set output[i] to 0 instead. + +## Documentation + +### Solution Idea & [Implementation](./solver.ts) + +The idea is straightforward: + +Loop over each number in the array. +For every number, start a second loop that goes through the remaining elements of the array, beginning at the next index. + +In this inner loop, check each number until you find one that is greater than the current number. +Count how many steps it takes to find such a number. + +- If a larger number is found, return the number of steps taken. +- If the end of the array is reached without finding a larger number, return `0`. + +Repeat this process for every number in the array. + +(Sorry for only one text. But don't want to write two :|) + +--- + +### Information's + +This problem comes from the newsletter [Sloth Bytes](https://slothbytes.beehiiv.com). +[Post](https://slothbytes.beehiiv.com/p/docker-for-dummies) from March 25, 2026. diff --git a/Problems/Daily Temperatures/daily temperatures.test.ts b/Problems/Daily-Temperatures/daily temperatures.test.ts similarity index 100% rename from Problems/Daily Temperatures/daily temperatures.test.ts rename to Problems/Daily-Temperatures/daily temperatures.test.ts diff --git a/Problems/Daily Temperatures/solver.ts b/Problems/Daily-Temperatures/solver.ts similarity index 100% rename from Problems/Daily Temperatures/solver.ts rename to Problems/Daily-Temperatures/solver.ts diff --git a/Problems/Vertical-List/README.md b/Problems/Vertical-List/README.md index 87d8c76..ad88617 100644 --- a/Problems/Vertical-List/README.md +++ b/Problems/Vertical-List/README.md @@ -22,6 +22,8 @@ If it does not exist, we know that the previous word was shorter, so we insert a By doing this for every word and every character, the solution array is built correctly and the final transformed text can be returned. +(Sorry for only one text. But don't want to write two :|) + --- ### Information's diff --git a/README.md b/README.md index 04aebcc..7ba56f6 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ This repository is about solving coding-problems. It contains famous (or not tha ## Problems -Solved: **27 problems** +Solved: **28 problems** -🟢 Easy: 21 +🟢 Easy: 22 🟠 Medium: 5 🔴 Hard: 1 @@ -41,6 +41,7 @@ Solved: **27 problems** | [Missing Number](./Problems/Missing-Number/README.md) | 🟢 Easy | | [Seven Boom!](./Problems/Seven-Boom/README.md) | 🟢 Easy | | [Vertical List](./Problems/Vertical-List/README.md) | 🟢 Easy | +| [Daily Temperatures](./Problems/Daily-Temperatures/README.md) | 🟢 Easy |