C-Plus-Plus icon indicating copy to clipboard operation
C-Plus-Plus copied to clipboard

feat: added LeetCode problem 1,2

Open nageshnnazare opened this issue 2 years ago • 8 comments

Created new directory for leetcode solutions, updated DIRECTORY.md and README.md

Description of Change

Checklist

  • [x] Added description of change
  • [x] Added file name matches File name guidelines
  • [x] Added tests and example, test must pass
  • [x] Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • [x] Relevant documentation/comments is changed or added
  • [x] PR title follows semantic commit guidelines
  • [x] Search previous suggestions before making a new one, as yours may be a duplicate.
  • [x] I acknowledge that all my contributions will be made under the project's license.

Notes:

nageshnnazare avatar Apr 14 '23 13:04 nageshnnazare

Hi @Panquesito7, @tjgurwara99 For problem 2, the CI is failing with the following warnings:

/home/runner/work/C-Plus-Plus/C-Plus-Plus/leetcode/src/2.cpp:29:9: warning: assigning newly created 'gsl::owner<>' to non-owner 'ListNode *' [cppcoreguidelines-owning-memory] sum->next = new ListNode(val%10); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/runner/work/C-Plus-Plus/C-Plus-Plus/leetcode/src/2.cpp:35:9: warning: assigning newly created 'gsl::owner<>' to non-owner 'ListNode *' [cppcoreguidelines-owning-memory] sum->next = new ListNode(carry); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I guess it is because of the use of raw pointers instead of smart pointers. Is there a way to suppress this?

(This may require changing the definition of the ListNode struct, which is already defined by the platform)

struct ListNode { int val; std::unique_ptr<ListNode> next; // Use unique_ptr here ... };

nageshnnazare avatar Apr 16 '23 13:04 nageshnnazare

Does this directory also fall under doxygen style guidelines?

realstealthninja avatar Apr 22 '23 15:04 realstealthninja

Does this directory also fall under doxygen style guidelines?

I believe so. Not required, but if added, it's better, IMO.

Panquesito7 avatar Apr 26 '23 17:04 Panquesito7

Is there a way to suppress this?

It'd be better to use smart pointers, though. I found this to convert raw to a smart pointer, it may help: https://www.sololearn.com/Discuss/1958592/how-can-i-replace-raw-pointers-with-smart-pointers

Panquesito7 avatar Apr 26 '23 17:04 Panquesito7

Does this directory also fall under doxygen style guidelines?

I believe so. Not required, but if added, it's better, IMO.

Ah alright!

realstealthninja avatar Apr 27 '23 00:04 realstealthninja

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 27 '23 00:05 github-actions[bot]

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 30 '23 00:06 github-actions[bot]

Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!

github-actions[bot] avatar Jul 07 '23 00:07 github-actions[bot]