Add docstring and type hints to two_sum#14008
Add docstring and type hints to two_sum#14008gokul000410 wants to merge 2 commits intoTheAlgorithms:masterfrom
Conversation
Raise ValueError if no two sum solution exists
mindaugl
left a comment
There was a problem hiding this comment.
It seems to be not finished, e.g., return statement is missing.
No , you can see return statement inside the loop if two sum == target it will return , why inside loop because there is always going to have one valid two sum that's equal to target ,if there is no two sum in the array it will raise the value error at the end this is just optional , because in two sum problem there is always going to have one valid two sum pair |
Thank you |
Description
This pull request adds a detailed docstring and type hints to the
two_sumimplementation in the arrays section.
The changes improve code readability and maintainability while keeping the
existing algorithm logic unchanged.
Changes Made
Checklist