Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork312
some code cleanup#4
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -9,6 +9,9 @@ | ||
*/ | ||
public class RemoveDuplicates { | ||
public static final String WITHOUT_DUPS = "Without dups: "; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Can be | ||
public static final String WITH_DUPS = "\nWith dups: "; | ||
/** | ||
* Removes duplicates in an unsorted linked list by using additional memory | ||
* and two references. | ||
@@ -44,7 +47,7 @@ public static void main(String[] args) { | ||
System.out.print("With dups: "); | ||
l1.print(); | ||
removeDuplicatesFromUnsortedList(l1); | ||
System.out.print(WITHOUT_DUPS); | ||
l1.print(); | ||
Node l2 = new Node(1); | ||
@@ -53,10 +56,10 @@ public static void main(String[] args) { | ||
l2.next.next.next = new Node(3); | ||
l2.next.next.next.next = new Node(4); | ||
l2.next.next.next.next.next = new Node(5); | ||
System.out.print(WITH_DUPS); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
| ||
l2.print(); | ||
removeDuplicatesFromUnsortedList(l2); | ||
System.out.print(WITHOUT_DUPS); | ||
l2.print(); | ||
Node l3 = new Node(1); | ||
@@ -65,24 +68,25 @@ public static void main(String[] args) { | ||
l3.next.next.next = new Node(3); | ||
l3.next.next.next.next = new Node(4); | ||
l3.next.next.next.next.next = new Node(5); | ||
System.out.print(WITH_DUPS); | ||
l3.print(); | ||
removeDuplicatesFromUnsortedList(l3); | ||
System.out.print(WITHOUT_DUPS); | ||
l3.print(); | ||
Node l4 = new Node(1); | ||
System.out.print(WITH_DUPS); | ||
l4.print(); | ||
removeDuplicatesFromUnsortedList(l4); | ||
System.out.print(WITHOUT_DUPS); | ||
l4.print(); | ||
Node l5 = null; | ||
System.out.print(WITH_DUPS); | ||
l5.print(); | ||
removeDuplicatesFromUnsortedList(l5); | ||
System.out.print(WITHOUT_DUPS); | ||
l5.print(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -38,7 +38,7 @@ private static int pop() { | ||
} | ||
private static Stack<Integer> getLastStack() { | ||
if (stackList.isEmpty() || isFull(stackList.get(stackList.size() - 1))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. 👍 | ||
stackList.add(new Stack<>()); | ||
} | ||
return stackList.get(stackList.size() - 1); | ||