Skip to content
Advertisement

How to insert a string in a circular linked list (i want to check the duplicate words in the circular linked list)?

Here is the linked class that I created and I wrote a method that checked if there was a duplicate words in my linked list. I tried to sent the string to the addFirst method but I don’t know why it doesn’t work with me

JavaScript

in the main i can’t insert the words to the circular linked list

JavaScript

Advertisement

Answer

sorry – a lot of things are wrong. Here is the code pleas study the difference to your. To initialize private class variables you must use the constructor. Your addFirst() method must take a String instead of a Node object. The output is:

-Examine node ‘place’ -Examine node ‘a better’ -Examine node ‘will’ -First duplicate is ‘will’ -true

JavaScript

} // end of class LinkedTest

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement