Are the Lists Equal
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
0 <= nodes in each list <= 50-100 <= Node.val <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Linked lists problems
- Average of the ValuesBeginner
- Balanced Open and CloseBeginner
- Binary Linked List to IntegerBeginner
- Build a Linked List From an ArrayBeginner
- Build a List of DigitsBeginner
- Build a Range ListBeginner
- Compare Two ListsBeginner
- Count Distinct ValuesBeginner