5.5 Python Uses ListNode instead of List throws error on Len

#1

Throws error Test UNHANDLED EXCEPTION ( 1/203) TypeError: object of type ‘ListNode’ has no len()
L: [-8, -8, -7, -5, -5, -4, 1, 2, 2, 2, 2, 4, 5, 5, 7, 7]
expected: [-8, -7, -5, -4, 1, 2, 4, 5, 7]

when running the test (the answer in the book uses len, and it clearly states that a list is the input)

0 Likes

#2

Please report this on our github page instead.

0 Likes

#3

@mtbsickrider, I take a look of that, it is because ListNode does not implement len method, and you can implement it if you want.

0 Likes

#4

Yeah, i believe ListNode is an implementation of LinkedList.

But im thinking the problem itself should be using a simple array and not this data structure.

So i guess the ask is making the test not ue listNode and use Array as input. I would have to check how the tests get generated.

0 Likes

#5

No this problem is set for ListNode instead of array. Array with random access makes this problem totally different.

0 Likes