From 2428c54edc6c4f8211a88745271989e4124eba00 Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:05:04 +0530 Subject: [PATCH 01/12] Update 02 - Implement Atoi.md Added level --- 2024/02-2024(feb)/02 - Implement Atoi.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/2024/02-2024(feb)/02 - Implement Atoi.md b/2024/02-2024(feb)/02 - Implement Atoi.md index 2e75518..dab75d3 100644 --- a/2024/02-2024(feb)/02 - Implement Atoi.md +++ b/2024/02-2024(feb)/02 - Implement Atoi.md @@ -1,6 +1,8 @@ ## 02. Implement Atoi The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/implement-atoi/1) +![](https://badgen.net/badge/Level/Medium/yellow) + ### My Approach I have implemented the Atoi function using a simple iteration through the input string. Here's a breakdown of the steps: From e95e6853f424bb3fdb81b4f04cf852f2228812a0 Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:06:18 +0530 Subject: [PATCH 02/12] Update README.md Added level --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 75ea666..c3fe543 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ ### Que - Implement Atoi The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/implement-atoi/1) +![](https://badgen.net/badge/Level/Medium/yellow) + ### My Approach I have implemented the Atoi function using a simple iteration through the input string. Here's a breakdown of the steps: From a8f36425c865766c5e9000c696bb07e04672c6ae Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:07:24 +0530 Subject: [PATCH 03/12] Update 22 - Paths from root with a specified sum.md Added level --- .../01-2024(jan)/22 - Paths from root with a specified sum.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2024/01-2024(jan)/22 - Paths from root with a specified sum.md b/2024/01-2024(jan)/22 - Paths from root with a specified sum.md index f578a7c..edd6816 100644 --- a/2024/01-2024(jan)/22 - Paths from root with a specified sum.md +++ b/2024/01-2024(jan)/22 - Paths from root with a specified sum.md @@ -1,6 +1,8 @@ ## 22. Paths from root with a specified sum The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/paths-from-root-with-a-specified-sum/1) +![](https://badgen.net/badge/Level/Medium/yellow) + ### My Approach - I used a recursive approach to traverse the tree and find paths with the specified sum. - For each node, I added its value to the current sum and checked if it equals the target sum. @@ -39,4 +41,4 @@ public: For discussions, questions, or doubts related to this solution, please visit our [discussion section](https://github.com/getlost01/gfg-potd/discussions). We welcome your input and aim to foster a collaborative learning environment. -If you find this solution helpful, consider supporting us by giving a `⭐ star` to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. \ No newline at end of file +If you find this solution helpful, consider supporting us by giving a `⭐ star` to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. From 8724e85613536467b76dd9fc2b56e635c274862a Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:07:54 +0530 Subject: [PATCH 04/12] Update 23 - Course Schedule.md Added level --- 2024/01-2024(jan)/23 - Course Schedule.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2024/01-2024(jan)/23 - Course Schedule.md b/2024/01-2024(jan)/23 - Course Schedule.md index 5c5eef6..f2a4b59 100644 --- a/2024/01-2024(jan)/23 - Course Schedule.md +++ b/2024/01-2024(jan)/23 - Course Schedule.md @@ -1,6 +1,8 @@ ## 23. Course Schedule The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/course-schedule/1) +![](https://badgen.net/badge/Level/Medium/yellow) + ### My Approach I am using a topological sorting approach to find the order of courses. The idea is to first create a directed graph representing the prerequisite relationships between courses. Then, I calculate the in-degree (number of incoming edges) for each course. Starting with the courses that have no prerequisites (in-degre e = 0), I use a queue to perform a topological sort. @@ -66,4 +68,4 @@ public: For discussions, questions, or doubts related to this solution, please visit our [discussion section](https://github.com/getlost01/gfg-potd/discussions). We welcome your input and aim to foster a collaborative learning environment. If you find this solution helpful, consider supporting us by giving a ⭐ star to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. -``` \ No newline at end of file +``` From ffb3f828f555c94e6d7e4d3a0dcf6d26b75bcb69 Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:08:24 +0530 Subject: [PATCH 05/12] Update 24 - Is it a tree.md added level --- 2024/01-2024(jan)/24 - Is it a tree.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2024/01-2024(jan)/24 - Is it a tree.md b/2024/01-2024(jan)/24 - Is it a tree.md index 442b7bd..bd9f273 100644 --- a/2024/01-2024(jan)/24 - Is it a tree.md +++ b/2024/01-2024(jan)/24 - Is it a tree.md @@ -1,6 +1,8 @@ ## 24. Is it a tree ? The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/is-it-a-tree/1) +![](https://badgen.net/badge/Level/Medium/yellow) + ### My Approach - Check if the difference between the number of nodes (n) and edges (m) is exactly 1. If not, it's not a tree. - Initialize a vector `vis` to keep track of visited nodes. @@ -52,4 +54,4 @@ public: For discussions, questions, or doubts related to this solution, please visit our [discussion section](https://github.com/getlost01/gfg-potd/discussions). We welcome your input and aim to foster a collaborative learning environment. -If you find this solution helpful, consider supporting us by giving a `⭐ star` to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. \ No newline at end of file +If you find this solution helpful, consider supporting us by giving a `⭐ star` to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. From 34fb5f3abc9f96d1fa55fbd9c50be8f827fdf1b4 Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:08:53 +0530 Subject: [PATCH 06/12] Update 25 - Shortest Prime Path.md added level --- 2024/01-2024(jan)/25 - Shortest Prime Path.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2024/01-2024(jan)/25 - Shortest Prime Path.md b/2024/01-2024(jan)/25 - Shortest Prime Path.md index e224141..1651be3 100644 --- a/2024/01-2024(jan)/25 - Shortest Prime Path.md +++ b/2024/01-2024(jan)/25 - Shortest Prime Path.md @@ -2,6 +2,8 @@ The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/shortest-prime-path--141631/1) +![](https://badgen.net/badge/Level/Medium/yellow) + ### My Approach - Create a sieve of Eratosthenes to efficiently check for prime numbers. @@ -78,4 +80,4 @@ public: For discussions, questions, or doubts related to this solution, please visit our [discussion section](https://github.com/getlost01/gfg-potd/discussions). We welcome your input and aim to foster a collaborative learning environment. If you find this solution helpful, consider supporting us by giving a ⭐ star to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. -``` \ No newline at end of file +``` From 6ba4af4452d08df4892529116a82006c64d378d0 Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:09:22 +0530 Subject: [PATCH 07/12] Update 26 - Fractional Knapsack.md Added level --- 2024/01-2024(jan)/26 - Fractional Knapsack.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2024/01-2024(jan)/26 - Fractional Knapsack.md b/2024/01-2024(jan)/26 - Fractional Knapsack.md index cd519ee..9ba8189 100644 --- a/2024/01-2024(jan)/26 - Fractional Knapsack.md +++ b/2024/01-2024(jan)/26 - Fractional Knapsack.md @@ -1,6 +1,8 @@ ## 26. Fractional Knapsack The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/fractional-knapsack-1587115620/1) +![](https://badgen.net/badge/Level/Medium/yellow) + ### My Approach - I implemented a greedy strategy to maximize the value per weight. - I sorted the items in descending order based on their value-to-weight ratios. @@ -44,4 +46,4 @@ public: For discussions, questions, or doubts related to this solution, please visit our [discussion section](https://github.com/getlost01/gfg-potd/discussions). We welcome your input and aim to foster a collaborative learning environment. -If you find this solution helpful, consider supporting us by giving a ⭐ star to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. \ No newline at end of file +If you find this solution helpful, consider supporting us by giving a ⭐ star to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. From f7a01f35676460a9bc36864ec5c28a3450402077 Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:10:19 +0530 Subject: [PATCH 08/12] Update 27 - Brackets in Matrix Chain Multiplication.md Added level --- .../27 - Brackets in Matrix Chain Multiplication.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2024/01-2024(jan)/27 - Brackets in Matrix Chain Multiplication.md b/2024/01-2024(jan)/27 - Brackets in Matrix Chain Multiplication.md index ec8f9ad..367352b 100644 --- a/2024/01-2024(jan)/27 - Brackets in Matrix Chain Multiplication.md +++ b/2024/01-2024(jan)/27 - Brackets in Matrix Chain Multiplication.md @@ -1,6 +1,8 @@ ## 27. Brackets in Matrix Chain Multiplication The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/brackets-in-matrix-chain-multiplication1024/1) +![](https://badgen.net/badge/Level/Hard/red) + ### My Approach I implemented the matrix chain multiplication using dynamic programming with bottom-up tabulation. The steps are as follows: @@ -52,4 +54,4 @@ public: For discussions, questions, or doubts related to this solution, please visit our [discussion section](https://github.com/getlost01/gfg-potd/discussions). We welcome your input and aim to foster a collaborative learning environment. -If you find this solution helpful, consider supporting us by giving a `⭐ star` to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. \ No newline at end of file +If you find this solution helpful, consider supporting us by giving a `⭐ star` to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. From a6e61e3c32b215a8e5bfaf903c7ae5bb8a5abd59 Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:10:52 +0530 Subject: [PATCH 09/12] Update 29 - Count digit groupings of a number.md Added level --- 2024/01-2024(jan)/29 - Count digit groupings of a number.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2024/01-2024(jan)/29 - Count digit groupings of a number.md b/2024/01-2024(jan)/29 - Count digit groupings of a number.md index c209175..2bf9c34 100644 --- a/2024/01-2024(jan)/29 - Count digit groupings of a number.md +++ b/2024/01-2024(jan)/29 - Count digit groupings of a number.md @@ -1,6 +1,8 @@ ## 29. Count digit groupings of a number The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/count-digit-groupings-of-a-number1520/1) +![](https://badgen.net/badge/Level/Medium/yellow) + ### My Approach - I use a recursive approach where I start iterating through the string from left to right. - For each digit, I add it to the current sum, and if the sum becomes greater than or equal to the current target sum, I recursively call the function with the updated parameters. @@ -49,4 +51,4 @@ public: For discussions, questions, or doubts related to this solution, please visit our [discussion section](https://github.com/getlost01/gfg-potd/discussions). We welcome your input and aim to foster a collaborative learning environment. -If you find this solution helpful, consider supporting us by giving a `⭐ star` to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. \ No newline at end of file +If you find this solution helpful, consider supporting us by giving a `⭐ star` to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. From 3bbabc19e20b2f7fbb409d0afc12bf575bc7ac3f Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:11:14 +0530 Subject: [PATCH 10/12] Update 30 - LCS of three strings.md Added level --- 2024/01-2024(jan)/30 - LCS of three strings.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2024/01-2024(jan)/30 - LCS of three strings.md b/2024/01-2024(jan)/30 - LCS of three strings.md index 924b372..9dbc47f 100644 --- a/2024/01-2024(jan)/30 - LCS of three strings.md +++ b/2024/01-2024(jan)/30 - LCS of three strings.md @@ -1,6 +1,8 @@ ## 30. LCS of three strings The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/lcs-of-three-strings0028/1) +![](https://badgen.net/badge/Level/Medium/yellow) + ### My Approach I have used dynamic programming to solve this problem. I created a 3D array `dp` to store the length of the Longest Common Subsequence (LCS) of substrings of A, B, and C. The recurrence relation is based on comparing characters at each position. If the characters are equal, I update the length based on the LCS of the substrings without these characters. The final answer is stored in `dp[n1][n2][n3]`, representing the LCS of the entire strings A, B, and C. @@ -34,4 +36,4 @@ public: For discussions, questions, or doubts related to this solution, please visit our [discussion section](https://github.com/getlost01/gfg-potd/discussions). We welcome your input and aim to foster a collaborative learning environment. -If you find this solution helpful, consider supporting us by giving a ⭐ star to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. \ No newline at end of file +If you find this solution helpful, consider supporting us by giving a ⭐ star to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. From bd0313f4f08f1ba37798adbd196fdd37b32c4ff7 Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:11:39 +0530 Subject: [PATCH 11/12] Update 31 - Insert and Search in a Trie.md Added level --- 2024/01-2024(jan)/31 - Insert and Search in a Trie.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2024/01-2024(jan)/31 - Insert and Search in a Trie.md b/2024/01-2024(jan)/31 - Insert and Search in a Trie.md index 25fb601..197f364 100644 --- a/2024/01-2024(jan)/31 - Insert and Search in a Trie.md +++ b/2024/01-2024(jan)/31 - Insert and Search in a Trie.md @@ -1,6 +1,8 @@ ## 31. Insert and Search in a Trie The problem can be found at the following link: [Question Link](https://www.geeksforgeeks.org/problems/lcs-of-three-strings0028/1) +![](https://badgen.net/badge/Level/Medium/yellow) + ### My Approach - For both `insert` and `search` functions, I'm using recursion to traverse the trie based on the characters of the input key. - In the `insert` function, if a character node is not present in the current TrieNode, I create a new node for that character and continue the insertion. @@ -45,4 +47,4 @@ public: For discussions, questions, or doubts related to this solution, please visit our [discussion section](https://github.com/getlost01/gfg-potd/discussions). We welcome your input and aim to foster a collaborative learning environment. -If you find this solution helpful, consider supporting us by giving a `⭐ star` to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. \ No newline at end of file +If you find this solution helpful, consider supporting us by giving a `⭐ star` to the [getlost01/gfg-potd](https://github.com/getlost01/gfg-potd) repository. From 1ca6be80f3429843a6dbd87a75651d0e2250c152 Mon Sep 17 00:00:00 2001 From: RahulKRaj7 <113328473+RahulKRaj7@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:14:16 +0530 Subject: [PATCH 12/12] Create readme.md For 02-2024(feb) directory. --- 2024/02-2024(feb)/readme.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 2024/02-2024(feb)/readme.md diff --git a/2024/02-2024(feb)/readme.md b/2024/02-2024(feb)/readme.md new file mode 100644 index 0000000..41e3d29 --- /dev/null +++ b/2024/02-2024(feb)/readme.md @@ -0,0 +1,7 @@ +## February - 2024 + +Welcome! to the directory that have the solutions for the GeeksforGeeks (GFG) Problem of the Day for the month of **February 2024**. + +Feel free to navigate through the directory and examine the solutions for each problem. Remember that understanding the logic behind each solution is crucial for your growth as a programmer. + +To access the original problem statements, please visit the **GFG [Problem of the Day](https://practice.geeksforgeeks.org/problem-of-the-day)** page.