FunctionRacerProblemsRace

Contains a Sublist

EasyLinked listsPython, JavaScript, TypeScript, Java, C++

Return True if the values of a appear in b as one unbroken stretch of consecutive nodes, in the same order. An empty a is contained in everything.

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 [2,3]
b [1,2,3,4]
returns true

2, 3 appear side by side in b.

Example 2

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

1 and 3 are not side by side.

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