Skip to content
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

Replaced Dictionary with HashSet and changed the corresponding methods. #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Replaced Dictionary with HashSet and changed the corresponding methods.
rajeshganesh committed Jul 24, 2018
commit 1374ebd3b406c0fd637032f3c9ba7ab72c262f81
6 changes: 3 additions & 3 deletions Ch 02. Linked Lists/Q2_01_Remove_Dups.cs
Original file line number Diff line number Diff line change
@@ -24,12 +24,12 @@ private void Tap(int i)

private void DeleteDupsA(LinkedListNode node)
{
var table = new Dictionary<int, bool>();
var table = new HashSet<int>();
LinkedListNode previous = null;

while (node != null)
{
if (table.ContainsKey(node.Data))
if (table.Contains(node.Data))
{
if (previous != null)
{
@@ -38,7 +38,7 @@ private void DeleteDupsA(LinkedListNode node)
}
else
{
table.Add(node.Data, true);
table.Add(node.Data);
previous = node;
}