-
Notifications
You must be signed in to change notification settings - Fork 13
Dev06 6 leet code add two num ricardo collado #20
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
Open
RicardoColladoRothschild
wants to merge
34
commits into
orodriguez:main
Choose a base branch
from
RicardoColladoRothschild:Dev06-6-LeetCode-AddTwoNum-Ricardo_Collado
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dev06 6 leet code add two num ricardo collado #20
RicardoColladoRothschild
wants to merge
34
commits into
orodriguez:main
from
RicardoColladoRothschild:Dev06-6-LeetCode-AddTwoNum-Ricardo_Collado
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… was not being added as it was comming form the array values
…method, create a complex logic to insert a new node when the list was empty, did not allow to insert, when the list was with one element, change head.2)During this commit there was a bug and fix it, when circle throught the linkedlist there was an infity bucle, fixed
* Test LnkList using AssertElementsCountAndLast * Introduce DoublyLnkList.cs and DoublyLnkListTests.cs
*Add a count-- to the remove() method on lnkList for both situations.
*Add a Previous property to LnkNode, for the DoublyLinklist
*Add implementantion complete to add method *Add implementation to ToArray[]
*Add an implemantation to the Insert method, for empty list, with only 1 element and several elements Last: *Add implementation to the return method 'Last' to be able to return the value of the last element
*Add implementation the the Remove method, failed test count: 21, passed 46
*RemoveAt_OnlyOne test passed, it was missing to decrease count
*Add a throw IndexOutOfRangeException, when attempting to remove any from an empty list
* Add implementation to get method. * Add and resolve test for removeat and remove
*Add count++ when adding new elements on Prepend
*Add a different implementation to the ToArray(), due to being with a while, it was throwing OutOfIndex Excep
* I was leaving a reference to the last node, even thought i was removing it. Clear this by directly refering the conexion to the node.next as null, and issue was fix. ALL TEST PASSEDgit add .!
…icardo Collado Rothschild
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solution given to LeetCode problem:
Using hashmap.
The solution is implemented to go throught the array that is passed as argument to the method.
Once we are circling throught the array, we use math formula to decrease the current element to the target, if it is
already in our hashmap, means that the current array position is the other number we are missing, and in the hashmap is the first one (which is the result from the decrease) and we just have to return that information.
If not, we procee and verify if this number already exist (current element), if not then we add it to the hashmap.
Originally, i was solving this problem with burble sort, simple going throught each element against each other element.
That solution Big O was = O(n^2). Using the hashmap, i decrease it to only 1 bucle, meaning it decrease to O(n).