Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-349

Trigram Total Count

Problem

The number of trigrams in a token list is max(0, len(tokens) - 2).

Given the token list, return the trigram count.

Hint

Each trigram consumes a window of three consecutive tokens.

Test cases

case 1
in: [["a","b","c","d"]]
expected: 2
case 2
in: [["a","b"]]
expected: 0
case 3
in: [[]]
expected: 0
Starter codePython
def trigram_total_count(tokens):
    # Your code here
    pass

3 test cases · run your code against them in the editor