HTML & JS
//c++ program to find a list in second list
#include<bits/stdc++.h>
using namespace std;
// Fills lps[] for given patttern pat[0..M-1]
void computeLPSArray(vector <int> pat, int M, int lps[] )
{
    // length of the previous longest prefix suffix
    int len = 0;
 
    lps[0] = 0; // lps[0] is always 0
 
    // the loop calculates lps[i] for i = 1 to M-1
    int i = 1;
    while (i < M)
    {
        if (pat[i] == pat[len])
        {
            len++;
            lps[i] = len;
            i++;
        }
        else // (pat[i] != pat[len])
        {
            if (len != 0)
            {
                len = lps[len-1];
 
                // Also, note that we do not increment
                // i here
            }
            else // if (len == 0)
            {
                lps[i] = 0;
                i++;
            }
        }
    }
}
 
// Prints occurrences of txt[] in pat[]
bool KMP(vector<int> pat, vector<int> txt)
{
    int M = pat.size();
    int N = txt.size();
 
    // create lps[] that will hold the longest prefix suffix
    // values for pattern
    int lps[M];
 
    // Preprocess the pattern (calculate lps[] array)
    computeLPSArray(pat, M, lps);
 
    int i = 0; // index for txt[]
    int j = 0; // index for pat[]
    while (i < N)
    {
        if (pat[j] == txt[i])
        {
            j++;
            i++;
        }
 
        if (j == M)
            return true;
 
        // mismatch after j matches
        else if (i < N && pat[j] != txt[i])
        {
            // Do not match lps[0..lps[j-1]] elements,
            // they will match anyway
            if (j != 0)
                j = lps[j-1];
            else
                i = i+1;
        }
    }
return false ;
}
 
 
// function return true if a list in second list 
bool ListFount ( list<int> list1 ,list<int> list2)
{
// create two empty array 
vector <int >temp1 ,temp2 ;
 
// store element of first list in temp1
for( auto i = list1.begin() ; i != list1.end() ;i++ )
        temp1.push_back((*i)) ;
         
// store element of second list in temp2
for( auto i = list2.begin() ; i != list2.end() ;i++ )
        temp2.push_back((*i)) ;
// Now Applies KMP ALGO 
return KMP( temp1 , temp2 );         
}
//driver program to test above function 
int main()
{
// List1 : 1->2->3->4
// list2 : 1->2->1->2->3->4
list< int > list1 ;
list< int > list2 ;
//insert element in list first 
list1.push_back(1);
list1.push_back(2);
list1.push_back(3);
list1.push_back(4);
//insert element in list first
list2.push_back(1);
list2.push_back(2);
list2.push_back(1);
list2.push_back(2);
list2.push_back(3);
list2.push_back(4);
 
ListFount ( list1 , list2 ) == true ?
     cout << "LIST FOUND" : cout << "LIST NOT FOUND "; 
return 0;
} 

Generated URL:

Output:

LIST FOUND
Report Bug