Kotlinlearncs.online LogoJava
Return to List

Solve: SimpleLinkedList Count Not Equal

Created By: Geoffrey Challen
/ Version: 2020.11.0

Create a public class CountLinkedList that extends SimpleLinkedList, which has an zero-argument constructor. Provide an instance method countNotEqual that accepts an Any as a parameter and returns how many values in the list are not equal to the passed value as an Int.

As a reminder, our SimpleLinkedList is composed of a chain of Items, where Item is defined as an inner class on SimpleLinkedList:

The SimpleLinkedList class also has a start property that refers to the start of the list, or null if the list is empty. Note that the list that you are extending does not have a size field or a get method, meaning that you will need to walk the list to solve this problem. (That's the point!)

Related Lessons

Stuck? You may find these lessons helpful: