Generate N-grams
Return contiguous n-grams as lists. Return [] when n is invalid or too large.
Examples
EXAMPLE WALKTHROUGHbigrams
A guided view of the published example, not a trace of your code.
INPUT
[["a","b","c"],2]TASKngrams()
EXPECTED OUTPUT
[["a","b"],["b","c"]]Start with the input values shown in this example.
Example 1 of 2
Input: tokens = ["a","b","c"], n = 2
Output: [["a","b"],["b","c"]]
Explanation: bigrams
Input: tokens = [1], n = 2
Output: []
Explanation: too large
Hint 1
There are len(tokens)-n+1 valid starts.