FunctionRacerProblemsRace

Are the Lists Equal

BeginnerLinked listsPython, JavaScript, TypeScript, Java, C++

Return True if lists a and b have the same length and hold the same values in the same order, otherwise False. Two empty lists are equal.

Linked lists appear in the tests as the list of their values, like [1,2,3]. Each node is a ListNode with .val and .next; the class is already defined for you.

Example 1

a [1,2,3]
b [1,2,3]
returns true

Same values, same order.

Example 2

a [1,2]
b [1,2,3]
returns false

Different lengths.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Linked lists problems