All problems
No-Repeat N-gram Check
Problem
Return True when no n-gram occurs more than once in tokens, and False otherwise.
If n <= 0 or the token list is shorter than n, return True vacuously.
Hint
Track n-grams in a set of tuples as you slide the window forward.
Test cases
case 1
in: [["a","b","a","b"],2]
expected: false
case 2
in: [["a","b","c","a","b"],2]
expected: false
case 3
in: [["a","b","c"],2]
expected: true
case 4
in: [["a","a"],1]
expected: false
case 5
in: [["a","b"],3]
expected: true
Starter codePython
def no_repeat_ngram_check(tokens, n):
# Your code here
pass5 test cases · run your code against them in the editor