Last active
December 16, 2015 20:39
-
-
Save hiroshi-maybe/5494372 to your computer and use it in GitHub Desktop.
A function to check sublist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var isSublist = function(a,b) { | |
| var a_idx=0; | |
| for(var b_idx=0; b_idx<b.length; b_idx+=1) { | |
| if (a[a_idx]==b[b_idx]) { | |
| if (a_idx==a.length-1) { | |
| return true; | |
| } | |
| a_idx+=1 ; | |
| } | |
| } | |
| return false; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment