Skip to content

Commit 82e3e47

Browse files
committed
feat: added header files to solutions to help CI
* Updated the leetcode Readme.md file
1 parent 29535e6 commit 82e3e47

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

leetcode/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ All LeetCode problems can be found [**here**](https://leetcode.com/problemset/al
2424
If you have a solution to any of these problems (which are not being **repeated**, that's great! Here are the steps:
2525

2626
1. Add a new file in `leetcode/src` with the number of the problem.
27-
- For example: if the problem's number is 98, the filename should be `98.cpp`.
27+
- For example: if the problem's number is 98, the filename should be `98.cpp`.
2828
2. Provide a small description of the solution at the top of the file. A function should go below that. For example:
2929

3030
```c
@@ -37,7 +37,7 @@ If you have a solution to any of these problems (which are not being **repeated*
3737

3838
3. Do not provide a `main` function. Use the required standalone functions instead.
3939
4. Doxygen documentation isn't used in LeetCode solutions. Simple/small documentation or comments should be fine.
40-
5. Don't include libraries/headers such as `iostream`. Your file should be the solution to the problem only.
40+
5. Please include dependency libraries/headers such as `<iostream>`, `<vector>` along with the `Solution` class to the problem. This will help the CI to succeed without the dependency errors.
4141

4242
> **Note**
4343
> There was a requirement to update the `leetcode/DIRECTORY.md` file with details of the solved problem. It's not required anymore. The information about the problem is fetched automatically throughout the LeetCode API.
@@ -66,4 +66,4 @@ git push origin solution/your-solution-name:solution/your-solution-name
6666

6767
4. You're done now! You just have to make a [**pull request**](https://github.com/TheAlgorithms/C-Plus-Plus/compare). 🎉
6868

69-
If you need any help, don't hesitate to ask and join our [**Discord server**](https://the-algorithms.com/discord)! 🙂
69+
If you need any help, don't hesitate to ask and join our [**Discord server**](https://the-algorithms.com/discord)! 🙂

leetcode/src/1.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
/*
2-
* Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
3-
* You may assume that each input would have exactly one solution, and you may not use the same element twice.
4-
*/
2+
* Given an array of integers nums and an integer target, return indices of the
3+
* two numbers such that they add up to target.
4+
* You may assume that each input would have exactly one solution, and you may not use the same element twice.
5+
*/
56

7+
#include <vector>
8+
#include <unordered_map>
69
class Solution {
710
public:
811
std::vector<int> twoSum(std::vector<int>& nums, int target) {

leetcode/src/2.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/* You are given two non - empty linked lists representing two non - negative integers.
2-
* The digits are stored in reverse order, and each of their nodes contains a single digit.
3-
* Add the two numbersand return the sum as a linked list.
4-
*/
2+
* The digits are stored in reverse order, and each of their nodes contains a single digit.
3+
* Add the two numbersand return the sum as a linked list.
4+
*/
55

66
/*
77
* Definition for singly-linked list.
8-
* struct ListNode {
9-
* int val;
10-
* ListNode *next;
11-
* ListNode() : val(0), next(nullptr) {}
12-
* ListNode(int x) : val(x), next(nullptr) {}
13-
* ListNode(int x, ListNode *next) : val(x), next(next) {}
14-
* };
158
*/
9+
struct ListNode {
10+
int val;
11+
ListNode *next;
12+
ListNode() : val(0), next(nullptr) {}
13+
ListNode(int x) : val(x), next(nullptr) {}
14+
ListNode(int x, ListNode *next) : val(x), next(next) {}
15+
};
16+
1617
class Solution {
1718
public:
1819
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {

0 commit comments

Comments
 (0)