Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Levels and readme.md #46

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
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.
4 changes: 3 additions & 1 deletion 2024/01-2024(jan)/23 - Course Schedule.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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.
```
```
4 changes: 3 additions & 1 deletion 2024/01-2024(jan)/24 - Is it a tree.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
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.
4 changes: 3 additions & 1 deletion 2024/01-2024(jan)/25 - Shortest Prime Path.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
```
```
4 changes: 3 additions & 1 deletion 2024/01-2024(jan)/26 - Fractional Knapsack.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
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.
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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.
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.
4 changes: 3 additions & 1 deletion 2024/01-2024(jan)/29 - Count digit groupings of a number.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
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.
4 changes: 3 additions & 1 deletion 2024/01-2024(jan)/30 - LCS of three strings.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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.
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.
4 changes: 3 additions & 1 deletion 2024/01-2024(jan)/31 - Insert and Search in a Trie.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
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.
2 changes: 2 additions & 0 deletions 2024/02-2024(feb)/02 - Implement Atoi.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
7 changes: 7 additions & 0 deletions 2024/02-2024(feb)/readme.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down