igorwojda/kotlin-coding-challenges

Error in solution for Queue with Linked List based implementation

ivaleev1997 opened this issue · 1 comments

Method remove() hasn't validate first node is null or size is 0 before decrease size. So size value may be less than zero if you invoke remove with empty queue.

        fun remove(): E? {
            val node = first
            first = node?.next
            size--
            return node?.data
        }

merci

Fixed by 530f48b