Skip to content

Conversation

@RicardoColladoRothschild

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).

“orodriguez” and others added 30 commits February 5, 2024 16:31
… 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 .!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant