Given two sequences $A$ and $B$, we want to check if $A$ is a subsequence of $B$ where the elements of $A$ appear in $B$ consecutively and in the same order.Example 1.input: $A = (4 , 6 , -5), B = (2 , 4 , 6 , -5 , 4)$, output: YesExample 2.input: $A = (2 , 6 , 4), B = (2 , 4 , 6 , -5 , 3)$, output: No  although $B$ contains all the elements in $A$, the order is not correct.Example 3.input: $A = (2 , 6 , 4), B = (2 , 3 , 6 , -5 , 4)$, output: No although $B$ contains all the elements of $A$ in the correct order, they are not consecutive.Let $n$ and $m$ be the size of $A$ and $B$.How fast can we solve this problem?What I have triedI have an algorithm that runs in time $O(nm)$ as follows:go over elements of A,  for each of them go over elements of B and see if we can find a matching element,  which is after the matching element for the previous element of A.
Check if an array is a substring of another array
algorithms;algorithm analysis;substrings